pcf.util package¶
Subpackages¶
Submodules¶
pcf.util.pcf_util module¶
-
pcf.util.pcf_util._update_dict(curr_dict, updated_dict, eval=False, diff_dict={}, root=True)¶
-
pcf.util.pcf_util.diff_dict(curr_dict, updated_dict)¶
-
pcf.util.pcf_util.extract_components_from_pcf_id(pcf_id)¶
-
pcf.util.pcf_util.find_nested_dict_value(curr_dict, list_nested_keys)¶
-
pcf.util.pcf_util.find_nested_vars(curr_dict, nested_key=None, var_list=[])¶ Returns a list of tuples with the nested key and var that needs to be replaced by parent
Parameters: - curr_dict (dict) – dictionary (can be nested)
- nested_key (str) – used for keeping track of nested keys for easy replaces later on
- var_list (list of tuples) – used to keep track of all key, var keep pair during recursion
Returns: [(nested_key, var_to_be_replaced), … ]
-
pcf.util.pcf_util.generate_pcf_id(flavor, pcf_name)¶
-
pcf.util.pcf_util.get_item_from_dicts(key, *dicts)¶
-
pcf.util.pcf_util.get_particle_unique_identifiers(flavor_name)¶ Gets the unique identifiers for the particle flavor. Uses the particle flavor scanner to search for the given particle.
Parameters: flavor_name (str) – particle flavor name Returns: unique identifiers (list)
-
pcf.util.pcf_util.get_value_from_particles(particles, particle_class, attr_name)¶ Searches a list for particles of a specified class and returns one of its attributes
Parameters: - particles (list) – list of particles
- particle_class (class) – class that is being searched for
- attr_name (string) – name of the attribute being returned
Returns: value of the attr
Return type: value (string)
-
pcf.util.pcf_util.is_dict_equal(dict_a, dict_b)¶
-
pcf.util.pcf_util.is_dict_update_needed(curr_dict, updated_dict)¶
-
pcf.util.pcf_util.is_list_equal(list_a, list_b)¶
-
pcf.util.pcf_util.keep_and_remove_keys(curr_dict, remove_dict)¶
-
pcf.util.pcf_util.keep_and_replace_keys(curr_dict, keep_replace_dict)¶
-
pcf.util.pcf_util.list_to_dict(key_name, dict_list)¶ Converts a list of dicts to a dictionary object
Parameters: - key_name (str) – field in dict whose unique value is used as the key
- dict_list (list) – list of dicts who has key_name
Returns: dict whose keys are the values of the key_name field
Return type: dict_from_list (dict)
-
pcf.util.pcf_util.param_filter(curr_dict, key_set, remove=False)¶ Filters param dictionary to only have keys in the key set
Parameters: - curr_dict (dict) – param dictionary
- key_set (set) – set of keys you want
- remove (bool) – filters by what to remove instead of what to keep
Returns: filtered param dictionary
-
pcf.util.pcf_util.particle_class_from_flavor(flavor)¶ Return the class object of the given flavor (or None) by searching through all particle and quasiparticle submodules in the pcf module
-
pcf.util.pcf_util.pkg_submodules(package, recursive=True)¶ Return a list of all submodules in a given package, recursively by default
-
pcf.util.pcf_util.replace_value_nested_dict(curr_dict, list_nested_keys, new_value)¶
-
pcf.util.pcf_util.transform_list_of_dicts_to_desired_list(curr_list, nested_key_name, new_list=[])¶ Returns a list of key values specified by the nested key
Parameters: - curr_list (list) – list of dicts to be dissected
- nested_key_name (str) – key name within nested dicts desired
- new_list (list) – used to append desired key values to new list
Returns: [nested_key_value, …]
-
pcf.util.pcf_util.update_dict(curr_dict, updated_dict)¶