h2integrate.core.dict_utils#
Functions
|
Check the user-input technology configuration inputs against the instantiated technology configuration classes to ensure that: |
|
Recursive method to convert arrays to lists and numerical entries to floats. |
|
Recursive method to remove keys from a dictionary. |
|
Recursively converts numpy array elements within a nested dictionary to lists and ensures all values are simple types (float, int, dict, bool, str) for writing to a YAML file. |
|
Rename |
|
Recursive method to update all entries in a dictionary with key 'keyname' with value 'new_val' |
|
Recursive method to copy value of |
- h2integrate.core.dict_utils.dict_to_yaml_formatting(orig_dict)#
Recursive method to convert arrays to lists and numerical entries to floats. This is primarily used before writing a dictionary to a YAML file to ensure proper output formatting.
- Parameters:
orig_dict (dict) – input dictionary
- Returns:
dict – input dictionary with reformatted values.
- h2integrate.core.dict_utils.remove_numpy(fst_vt)#
Recursively converts numpy array elements within a nested dictionary to lists and ensures all values are simple types (float, int, dict, bool, str) for writing to a YAML file.
- Parameters:
fst_vt (dict) – The dictionary to process.
- Returns:
dict –
- The processed dictionary with numpy arrays converted to lists
and unsupported types to simple types.
- Return type:
dict
- h2integrate.core.dict_utils.update_defaults(orig_dict, keyname, new_val)#
Recursive method to update all entries in a dictionary with key ‘keyname’ with value ‘new_val’
- Parameters:
orig_dict (dict) – dictionary to update
keyname (str) – key corresponding to value to update
new_val (any) – value to use for
keyname
- Returns:
dict – updated version of orig_dict
- h2integrate.core.dict_utils.update_keyname(orig_dict, init_key, new_keyname)#
Recursive method to copy value of
orig_dict[init_key]toorig_dict[new_keyname]- Parameters:
orig_dict (dict) – dictionary to update.
init_key (str) – existing key
new_keyname (str) – new key to replace
init_key
- Returns:
dict – updated dictionary
- h2integrate.core.dict_utils.remove_keynames(orig_dict, init_key)#
Recursive method to remove keys from a dictionary.
- Parameters:
orig_dict (dict) – input dictionary
init_key (str) – key name to remove from dictionary
- Returns:
dict – dictionary without any keys named init_key
- h2integrate.core.dict_utils.rename_dict_keys(input_dict, init_keyname, new_keyname)#
Rename
input_dict[init_keyname]toinput_dict[new_keyname]- Parameters:
input_dict (dict) – dictionary to update
init_keyname (str) – existing key to replace
new_keyname (str) – new keyname
- Returns:
dict – updated dictionary
- h2integrate.core.dict_utils.check_inputs(prob, tech, tech_info, tech_config_path)#
Check the user-input technology configuration inputs against the instantiated technology configuration classes to ensure that:
All user-input parameters are used in at least 1 configuration class
User-input shared_parameters are shared across at least 2 configuration classes
User-input parameters that are not shared are only used in 1 configuration class
- Parameters:
prob (om.Problem) – OpenMDAO problem defined in H2IntegrateModel
tech (str) – name of technology that the tech_info is for.
tech_info (dict) – technology input dictionary, including the technology model names and model_inputs.
tech_config_path (str or Path, optional) – path to the technology configuration file. Used in error messages to help the user locate the problematic section.
- Raises:
AttributeError – Raised if any of the 3 conditions are not met.