ParameterDict
- class mcalf.utils.collections.ParameterDict(dict=None, /, **kwargs)[source]
Bases:
BaseParameterDict
,UserDict
An unordered dictionary of
Parameter
objects.The same parameters existing across multiple dictionary values can be kept in sync with each other. For a
Parameter
object to be kept in sync it must be located in the dictionary such that{key: Parameter}
or{key: List[Parameter]}
.Examples
>>> d = ParameterDict({ ... 'a': Parameter('x') + 1, ... 'b': [2, Parameter('x'), 5], ... 'c': {1, 2, 3}, ... }) >>> d {'a': 'x+1', 'b': [2, 'x', 5], 'c': {1, 2, 3}} >>> d.update_parameter('x', 1) >>> d.eval() {'a': 2, 'b': [2, 1, 5], 'c': {1, 2, 3}}