edges_cal.tools.dct_of_list_to_list_of_dct

edges_cal.tools.dct_of_list_to_list_of_dct(dct: dict[str, Sequence]) list[dict][source]

Take a dict of key: list pairs and turn it into a list of all combos of dicts.

Parameters:

dct – A dictionary for which each value is an iterable.

Returns:

list – A list of dictionaries, each having the same keys as the input dct, but in which the values are the elements of the original iterables.

Examples

>>> dct_of_list_to_list_of_dct(
>>>    { 'a': [1, 2], 'b': [3, 4]}
[
    {"a": 1, "b": 3},
    {"a": 1, "b": 4},
    {"a": 2, "b": 3},
    {"a": 2, "b": 4},
]