mechanoChemML.src.dictionary¶
Module Contents¶
Functions¶
_copier(key, value, _copy) |
Copy value based on associated key |
_clone(iterable, twin, _copy=False) |
Shallow in-place copy of iterable to twin |
_set(iterable, elements, value, _split=False, _copy=False, _reset=True) |
Set nested value in iterable with nested elements keys |
_get(iterable, elements, default=None, _split=False, _copy=False) |
Get nested value in iterable with nested elements keys |
_pop(iterable, elements, default=None, _split=False, _copy=False) |
Pop nested value in iterable with nested elements keys |
_has(iterable, elements, _split=False) |
Check if nested iterable has nested elements keys |
_update(iterable, elements, _copy=False, _clear=True, _func=None) |
Update nested iterable with elements |
_permute(dictionary, _copy=False, _groups=None, _ordered=True) |
Get all combinations of values of dictionary of lists |
_find(iterable, key) |
Find and yield key in nested iterable |
_replace(iterable, key, replacement, _append=False, _copy=True, _values=False) |
Find and replace key in-place in iterable with replacement key |
_formatstring(key, iterable, elements, *args, **kwargs) |
Format values in iterable based on key and elements |
-
mechanoChemML.src.dictionary._copier(key, value, _copy)[source]¶ Copy value based on associated key
Parameters: Returns: Copy of value
-
mechanoChemML.src.dictionary._clone(iterable, twin, _copy=False)[source]¶ Shallow in-place copy of iterable to twin
Parameters:
-
mechanoChemML.src.dictionary._set(iterable, elements, value, _split=False, _copy=False, _reset=True)[source]¶ Set nested value in iterable with nested elements keys
Parameters: - iterable (dict) – dictionary to be set in-place with value
- elements (str,list) – DELIMITER separated string or list to nested keys of location to set value
- value (python object) – data to be set in iterable
- _split (bool,str,None) – boolean or None or delimiter on whether to split string elements into list of nested keys
- _copy (bool,dict,None) – boolean or None whether to copy value, or dictionary with keys on whether to copy value
- _reset (bool) – boolean on whether to replace value at key with value, or update the nested dictionary
-
mechanoChemML.src.dictionary._get(iterable, elements, default=None, _split=False, _copy=False)[source]¶ Get nested value in iterable with nested elements keys
Parameters: - iterable (dict) – dictionary of values
- elements (str,list) – DELIMITER separated string or list to nested keys of location to get value
- default (python object) – default data to return if elements not in nested iterable
- _split (bool,str,None) – boolean or None or delimiter on whether to split string elements into list of nested keys
- _copy (bool,dict,None) – boolean or None whether to copy value, or dictionary with keys on whether to copy value
Returns: Value at nested keys elements of iterable
-
mechanoChemML.src.dictionary._pop(iterable, elements, default=None, _split=False, _copy=False)[source]¶ Pop nested value in iterable with nested elements keys
Parameters: - iterable (dict) – dictionary to be popped in-place
- elements (str,list) – DELIMITER separated string or list to nested keys of location to pop value
- default (python object) – default data to return if elements not in nested iterable
- _split (bool,str,None) – boolean or None or delimiter on whether to split string elements into list of nested keys
- _copy (bool,dict,None) – boolean or None whether to copy value, or dictionary with keys on whether to copy value
Returns: Value at nested keys elements of iterable
-
mechanoChemML.src.dictionary._has(iterable, elements, _split=False)[source]¶ Check if nested iterable has nested elements keys
Parameters: Returns: Boolean value if nested keys elements are in iterable
-
mechanoChemML.src.dictionary._update(iterable, elements, _copy=False, _clear=True, _func=None)[source]¶ Update nested iterable with elements
Parameters: - iterable (dict) – dictionary to be updated in-place
- elements (dict) – dictionary of nested values to update iterable
- _copy (bool,dict,None) – boolean or None whether to copy value, or dictionary with keys on whether to copy value
- _clear (bool) – boolean of whether to clear iterable when the element’s value is an empty dictionary
- _func (callable,None) – Callable function that accepts key,iterable,elements arguments to modify value to be updated based on the given dictionaries
-
mechanoChemML.src.dictionary._permute(dictionary, _copy=False, _groups=None, _ordered=True)[source]¶ Get all combinations of values of dictionary of lists
Parameters: - dictionary (dict) – dictionary of keys with lists of values to be combined in all combinations across lists
- _copy (bool,dict,None) – boolean or None whether to copy value, or dictionary with keys on whether to copy value
- _groups (list,None) – List of lists of groups of keys that should not have their values permuted in all combinations, but should be combined in sequence element wise. For example groups = [[key0,key1]], where dictionary[key0] = [value_00,value_01,value_02],dictionary[key1] = [value_10,value_11,value_12], then the permuted dictionary will have key0 and key1 keys with only pairwise values of [{key0:value_00,key1:value_10},{key0:value_01,key1:value_11},{key0:value_02,key1:value_12}].
- _ordered (bool) – Boolean on whether to return dictionaries with same ordering of keys as dictionary
Returns: List of dictionaries with all combinations of lists of values in dictionary
-
mechanoChemML.src.dictionary._find(iterable, key)[source]¶ Find and yield key in nested iterable
Parameters: - iterable (dict) – dictionary to search
- key (python object) – key to find in iterable dictionary
Yields: Found values with key in iterable
-
mechanoChemML.src.dictionary._replace(iterable, key, replacement, _append=False, _copy=True, _values=False)[source]¶ Find and replace key in-place in iterable with replacement key
Parameters: - iterable (dict) – dictionary to be searched
- key (python object) – key to be replaced with replacement key
- replacement (python object) – dictionary key to replace key
- _append (bool) – boolean on whether to append replacement key to dictionary with value associated with key
- _copy (bool,dict,None) – boolean or None whether to copy value, or dictionary with keys on whether to copy value
- _values (bool) – boolean of whether to replace any values that equal key with replacement in the iterable