alogos._utilities.parametrization
¶
Classes¶
A collection of parameters with initial values that can be changed by a user. |
Functions¶
|
Get a parameter from a collection of given parameters or otherwise from defaults. |
Detailed object descriptions¶
- class alogos._utilities.parametrization.ParameterCollection(parameter_dict)[source]¶
A collection of parameters with initial values that can be changed by a user.
Provided features:
The set of available parameter names is defined once and for all by a dict passed to
__init__
.The user can get and set parameter values by dot notation (via
__setattr__
, e.g.param.a = 4
) and bracket notation (via__getitem__
and__setitem__
, e.g.param['a'] = 4
).The user can check if a parameter name is included in the collection (via __contains__, e.g. ‘a’ in param).
If a user tries to get or set an unknown parameter (detected via
__getattr__
), an error is raised, which lists all available parameters and their current and initial values. Note that there is a deliberate asymmetry between__setattr__
and__getattr__
in Python 3. The former is called on any attribute assignment, but the latter is only called when attribute lookup fails by all other methods.
References