utils
clean_types(d)
cleans up nested dict/list/tuple/other d
for exporting as yaml
Converts library specific types to python native types, including numpy dtypes, OrderedDict, numpy arrays
https://stackoverflow.com/questions/59605943/python-convert-types-in-deeply-nested-dictionary-or-array
Source code in slimfit/utils.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
format_indexer(indexer)
Format a tuple of slice objects into a string that can be used to index a numpy array.
More or less the inverse of numpy.index_exp
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indexer
|
tuple[slice, int, None, Ellipsis]
|
Tuple of indexing objects. |
required |
Source code in slimfit/utils.py
122 123 124 125 126 127 128 129 130 131 132 133 |
|
get_bounds(parameters)
Get bounds for minimization. Args: parameters: Iterable of Parameter objects.
Returns:
Type | Description |
---|---|
Optional[list[tuple[Optional[float], Optional[float]]]]
|
Either a list of tuples to pass to |
Source code in slimfit/utils.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
intersecting_component_symbols(model_components, symbols)
Finds and groups model components which have intersecting symbols.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_components
|
list[tuple[Symbol, NumExprBase]]
|
Model components. |
required |
symbols
|
set[Symbol]
|
Set of symbols to consider for intersections. |
required |
Returns:
Type | Description |
---|---|
list[Model]
|
Reconstructed models (assuming orignal model was a product of models). |
Source code in slimfit/utils.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 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 |
|