libb.align_iterdict

align_iterdict(iterdict_a, iterdict_b, **kw)[source]

Given two lists of dicts (‘iterdicts’), sorted on some attribute, build a single list with dicts, with keys within a given tolerance anything that cannot be aligned is DROPPED

>>> list(zip(*align_iterdict(
... [{'a': 1}, {'a': 2}, {'a': 5}],
... [{'b': 5}],
... a='a',
... b='b',
... diff=lambda x, y: x - y,
... )))
[({'a': 5},), ({'b': 5},)]
>>> list(zip(*align_iterdict(
... [{'b': 5}],
... [{'a': 1}, {'a': 2}, {'a': 5}],
... a='b',
... b='a',
... diff=lambda x, y: x - y
... )))
[({'b': 5},), ({'a': 5},)]