set_defaults
despasito.utils.general_toolbox.set_defaults
- set_defaults(dictionary, keys, values, lx=None)[source]
This function checks a dictionary for the given keys, and if it’s not there, the appropriate value is added to the dictionary.
- Parameters:
dictionary (dict) – Dictionary of data
keys (list) – Keys that should be present (of the same length as
lx)values (list) – Default values for the keys that aren’t in dictionary
lx (int, Optional, default=None) – If not None, and values[i] is a float, the key will be set to an array of length,
lx, populated byvalues[i]
- Returns:
new_dictionary – Dictionary of arrays of identical size.
- Return type:
dict