quast_decisiontree.core.data_handling
quast_decisiontree.core.data_handling
logger
module-attribute
logger = logging.getLogger('dt_logger')
load_config
load_config(filename)
Loads a yaml file into a dictionary as required by all configuration routines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str | Path
|
The file path of the yaml file. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary with the content of the yaml file, or an empty dict if the file is not found. |
Source code in src/quast_decisiontree/core/data_handling.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
save_dict
save_dict(
dict_to_save,
folder,
filename="dict.json",
filetype="json",
no_save_keys=None,
)
Will save the dictionary in question as far as possible, skipping keys that can't be put into a JSON-compatible format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dict_to_save
|
dict
|
the dictionary to save |
required |
folder
|
str
|
the folder where to save the dictionary to |
required |
filename
|
str
|
the filename |
'dict.json'
|
filetype
|
str
|
json or yaml |
'json'
|
no_save_keys
|
list
|
Any keys at the top level that will not be saved |
None
|
Returns:
| Type | Description |
|---|---|
set
|
the set of top-level keys that couldn't be serialized |
Source code in src/quast_decisiontree/core/data_handling.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
register_serializer
register_serializer(func)
Register a converter.
The converter must return a JSON-safe value or raise NotSerializableError if it does not handle the given item.
Source code in src/quast_decisiontree/core/data_handling.py
91 92 93 94 95 96 97 98 | |
convert_to_serializable
convert_to_serializable(item)
Convert a single item to a JSON-safe value using registered serializers.
Raises NotSerializableError if no registered serializer handles the item.
Source code in src/quast_decisiontree/core/data_handling.py
101 102 103 104 105 106 107 108 109 110 111 | |
deep_convert
deep_convert(obj)
Recursively convert a nested structure into a JSON-safe equivalent.
Mapping entries that cannot be serialized are skipped and logged at debug level.
Source code in src/quast_decisiontree/core/data_handling.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |