Perform calculations
find_formulas(dictionary)
finds all formulas in a nested dictionary
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dictionary
|
dict[str, Any]
|
config dictionary |
required |
Returns:
Type | Description |
---|---|
dict[tuple[str, ...], str]
|
dict[tuple[str, ...], str]: dictionary of formulas. Keys are a tuple of keys to access the value in the tree |
Source code in configcalc/perform_calcs.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
find_var_ref_indices(parsed_lists)
find positions of var values in parsed formulas from the parser as a list of indices of all variables
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parsed_lists
|
list[Any]
|
parsed formula |
required |
Returns:
Type | Description |
---|---|
list[list[int]]
|
list[list[int]]: description |
Source code in configcalc/perform_calcs.py
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 |
|
get_value_in_data(data, list_identifier)
get the value of a variable from its list identifier
Source code in configcalc/perform_calcs.py
80 81 82 83 84 85 |
|
perform_calculations(config, context_variables=None, number_type=NumberType.FLOAT)
resolves all possible calculations in config dictionary
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
dict[str, Any]
|
config dictionary as given by read_config_file |
required |
context_variables
|
dict[str, Any] | None
|
additional variable values to use for calculations. Defaults to None. |
None
|
number_type
|
NumberType
|
number type to use (e.g. NumberType.DECIMAL). Defaults to FLOAT. |
FLOAT
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
dict[str, Any]: config dictionary with all calculations resolved |
Source code in configcalc/perform_calcs.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
|