quast_decisiontree.core.utils
quast_decisiontree.core.utils
reset_data
reset_data()
Source code in src/quast_decisiontree/core/utils.py
16 17 18 19 20 | |
add_new_keys
add_new_keys(dict1, dict2, ignore=None)
adds all items from dict2 whose keys aren't contained in dict1
Mutates dict1 in place and returns it (not a copy).
ignore (optional, list): keys from dict2 that should not be added
Source code in src/quast_decisiontree/core/utils.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
load_file_if_not_none
load_file_if_not_none(path)
loads the dictionary at the specified path if not None, else returns an empty dictionary
Source code in src/quast_decisiontree/core/utils.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
expand_data_path
expand_data_path(config_dict, cwd=None)
if a data_folder key is contained in the dictionary, it will be expanded to a real path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_dict
|
dict
|
the dictionary |
required |
cwd
|
Union[str, None]
|
if a relative path is encountered, this will be taken |
None
|
Source code in src/quast_decisiontree/core/utils.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
read_config
read_config(
config_dict=None,
config_path=None,
standard_config_path=None,
)
generates a config dictionary from the arguments with the priority
config_dict > file at config_path > file at standard_config_path
Source code in src/quast_decisiontree/core/utils.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
cnf_list
cnf_list(input_, dtype=str)
converts the input to a list in conjunctive-normal form with dtype specifying the base unit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
Any
|
the input. Can be - either a single value of type dtype - a list of values of type dtype - a list where each element is either of the two above |
required |
Returns:
| Type | Description |
|---|---|
|
List[List[dtype]]: A nested list. All inputs are cast into the form [[dtype1, dtype2...], [dtype3, dtype4...]]. If the input list is [dtype1, dtype 2] the output is [[dtype1], [dtype2]], and not simply np.atleast_2d(input) |
Source code in src/quast_decisiontree/core/utils.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
flatten_cnf
flatten_cnf(cnf_list)
flattens a list in conjunctive normal form, eliminating possible duplicate entries while doing so.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cnf_list
|
list
|
A list of lists, where each inner list represents an or_clause that should be combined in an AND manner in the outer layer. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
A list containing each key appearing in an or clause, in first-seen order and without duplicates. |
Source code in src/quast_decisiontree/core/utils.py
147 148 149 150 151 152 153 154 155 156 157 158 159 | |
to_abspath_if_not_none
to_abspath_if_not_none(path)
Converts a path containing symbolic links into an abspath. If None is passed, None is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, None]
|
the input path, or None |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Union[str, None]: the output path, or None |
Source code in src/quast_decisiontree/core/utils.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
print_dictionary
print_dictionary(dictionary, title='', key_width=20)
Source code in src/quast_decisiontree/core/utils.py
179 180 181 | |
fmt_dictionary
fmt_dictionary(dictionary, title='', key_width=20)
Source code in src/quast_decisiontree/core/utils.py
184 185 186 187 188 189 190 191 192 193 194 | |
create_folder
create_folder(base_folder, folder_name)
creates a folder and returns it full path
Source code in src/quast_decisiontree/core/utils.py
197 198 199 200 201 | |