mlm_insights.core.utils package¶
Subpackages¶
Submodules¶
mlm_insights.core.utils.feature_component module¶
- mlm_insights.core.utils.feature_component.dict_factory(data: List[Tuple[str, Any]]) Dict[str, Any] ¶
- mlm_insights.core.utils.feature_component.flatten_dict(d: Dict[str, Any], sep: str = '.') Dict[str, Any] ¶
- mlm_insights.core.utils.feature_component.flatten_dict_for_standard_metric_result(d: Dict[str, Any], sep: str = '.') Dict[str, Any] ¶
mlm_insights.core.utils.hash module¶
- mlm_insights.core.utils.hash.compute_md5_hash(value: Any) str ¶
mlm_insights.core.utils.klasses module¶
- mlm_insights.core.utils.klasses.get_class(klass: Any, name: str) Any ¶
- mlm_insights.core.utils.klasses.get_subclasses_map(klass: Any) Dict[str, Any] ¶
mlm_insights.core.utils.common_utils module¶
- mlm_insights.core.utils.common_utils.create_dataclass_param(dict_repr: Dict[str, Any]) Struct ¶
- mlm_insights.core.utils.common_utils.get_nested_value(item: Any, key: str) Any ¶
Retrieve the value from a nested dictionary given a dot-separated key.
This function takes a dictionary and a dot-separated string representing a nested key, and returns the value associated with that key. If any key in the path does not exist, it returns None.
Parameters¶
- itemAny
The dictionary or dictionary-like object from which to retrieve the value.
- keystr
The dot-separated string representing the nested key.
Returns¶
- Any
The value associated with the nested key, or None if any key in the path does not exist.
Examples¶
>>> data = {'a': {'b': {'c': 42}}} >>> get_nested_value(data, 'a.b.c') 42 >>> get_nested_value(data, 'a.b.x') None
- mlm_insights.core.utils.common_utils.is_integer(element: Any) bool ¶
- mlm_insights.core.utils.common_utils.merge_dictionaries(new_dict: Dict[str, Any], target_dict: Dict[str, Any]) Dict[str, Any] ¶
Merge two dictionaries, ensuring keys from new_dict are added to target_dict only if they do not already exist in target_dict.
- Args:
new_dict (Dict[str, Any]): Dictionary containing new key-value pairs to add. target_dict (Dict[str, Any]): Dictionary to which new key-value pairs are added.
- Returns:
Dict[str, Any]: Merged dictionary with contents from target_dict updated with new key-value pairs from new_dict that were not already present.
- Example:
>>> dict1 = {'a': 1, 'b': 2, 'c': 3} >>> dict2 = {'b': 20, 'd': 40, 'e': 50} >>> merge_dictionaries(dict2, dict1) {'a': 1, 'b': 2, 'c': 3, 'd': 40, 'e': 50}
- mlm_insights.core.utils.common_utils.sort_config(dict_to_sort: Dict[str, Any]) Dict[str, Any] ¶