alogos._utilities.parametrization

Classes

ParameterCollection

A collection of parameters with initial values that can be changed by a user.

Functions

get_given_or_default(name, given_parameters, default_parameters)

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

__init__(self, parameter_dict)[source]

Create a parameter collection from a dictionary.

keys(self)[source]

Get parameter names.

values(self)[source]

Get parameter values.

items(self)[source]

Get parameter names and values.

alogos._utilities.parametrization.get_given_or_default(name, given_parameters, default_parameters)[source]

Get a parameter from a collection of given parameters or otherwise from defaults.