vivarium.library.dict_utils module

vivarium.library.dict_utils.deep_merge(dct, merge_dct)[source]

Recursive dict merge This mutates dct - the contents of merge_dct are added to dct (which is also returned). If you want to keep dct you could call it like deep_merge(dict(dct), merge_dct)

vivarium.library.dict_utils.deep_merge_check(dct, merge_dct)[source]

Recursive dict merge, which throws exceptions for conflicting values This mutates dct - the contents of merge_dct are added to dct (which is also returned). If you want to keep dct you could call it like deep_merge(dict(dct), merge_dct)

vivarium.library.dict_utils.deep_merge_combine_lists(dct, merge_dct)[source]

Recursive dict merge, combines values that are lists This mutates dct - the contents of merge_dct are added to dct (which is also returned). If you want to keep dct you could call it like deep_merge(dict(dct), merge_dct)

vivarium.library.dict_utils.flatten_port_dicts(dicts)[source]
Input:

dicts (dict): embedded state dictionaries with the {‘port_id’: {‘state_id’: state_value}}

Returns

flattened dictionary with {‘state_id_port_id’: value}

Return type

merge (dict)

vivarium.library.dict_utils.flatten_timeseries(timeseries)[source]

Flatten a timeseries in the style of flatten_port_dicts

vivarium.library.dict_utils.get_path_list_from_dict(dictionary)[source]
vivarium.library.dict_utils.get_value_from_path(dictionary, path)[source]
vivarium.library.dict_utils.keys_list(d)[source]
vivarium.library.dict_utils.make_path_dict(embedded_dict)[source]

converts embedded dict to a flat dict with path names as keys

vivarium.library.dict_utils.make_str_dict(dictionary)[source]
vivarium.library.dict_utils.merge_dicts(dicts)[source]
vivarium.library.dict_utils.str_to_tuple_keys(dictionary)[source]
vivarium.library.dict_utils.tuple_to_str_keys(dictionary)[source]
vivarium.library.dict_utils.tuplify_port_dicts(dicts)[source]
Input:

dicts (dict): embedded state dictionaries with the {‘port_id’: {‘state_id’: state_value}}

Returns

tuplified dictionary with {(port_id’,’state_id’): value}

Return type

merge (dict)

vivarium.library.dict_utils.value_in_embedded_dict(data, timeseries={}, time_index=None)[source]

converts data from a single time step into an embedded dictionary with lists of values