utils
clean_dic(o)
Convert numpy types to standard types in a nested dictionary containing number and lists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
o
|
Any
|
The object to convert. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/utils/dic_utils.py
find_item_in_dic(obj, key)
Find an item in a nested dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
dict
|
The nested dictionary. |
required |
key
|
str
|
The key to find in the nested dictionary. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The value corresponding to the key in the nested dictionary. |
Source code in study_da/utils/dic_utils.py
load_dic_from_path(path, ryaml=None)
Load a dictionary from a yaml file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The path to the yaml file. |
required |
ryaml
|
YAML
|
The yaml reader. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[dict, YAML]
|
tuple[dict, ruamel.yaml.YAML]: The dictionary and the yaml reader. |
Source code in study_da/utils/dic_utils.py
load_template_configuration_as_dic(template_configuration_name)
Load a template configuration as a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_configuration_name
|
str
|
The name of the template configuration. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
tuple[dict, YAML]
|
The template dictionary. |
Source code in study_da/utils/template_utils.py
load_template_script_as_str(template_script_name)
Load a template script as a string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_script_name
|
str
|
The name of the template script. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The template script as a string. |
Source code in study_da/utils/template_utils.py
nested_get(dic, keys)
Get the value from a nested dictionary using a list of keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dic
|
dict
|
The nested dictionary. |
required |
keys
|
list
|
The list of keys to traverse the nested dictionary. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The value corresponding to the keys in the nested dictionary. |
Source code in study_da/utils/dic_utils.py
nested_set(dic, keys, value)
Set a value in a nested dictionary using a list of keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dic
|
dict
|
The nested dictionary. |
required |
keys
|
list
|
The list of keys to traverse the nested dictionary. |
required |
value
|
Any
|
The value to set in the nested dictionary. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/utils/dic_utils.py
set_item_in_dic(obj, key, value, found=False)
Set an item in a nested dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
dict
|
The nested dictionary. |
required |
key
|
str
|
The key to set in the nested dictionary. |
required |
value
|
Any
|
The value to set in the nested dictionary. |
required |
found
|
bool
|
Whether the key has been found in the nested dictionary. |
False
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/utils/dic_utils.py
write_dic_to_path(dic, path, ryaml=None)
Write a dictionary to a yaml file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dic
|
dict
|
The dictionary to write. |
required |
path
|
str
|
The path to the yaml file. |
required |
ryaml
|
YAML
|
The yaml reader. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
None |