Formula

class minkit.Formula(name, formula, pars)[source]

Bases: minkit.ParameterBase

Parameter representing an operation of many parameters. The formula can be expressed as a function of parameter names, as a function of indices or a mixture of the two, like:

  • Parameter names: “a * b” will multiply a and b.

  • Indices: “{0} * {1}” will multiply the first and second elements in pars.

  • Mixed: “{a} * {b} + {1}” will multiply a and b and sum the second element in pars.

Parameters
  • name (str) – name of the parameter.

  • formula (str) – formula to apply. Any function defined in math is allowed.

  • pars (Registry) – input parameters.

Attributes Summary

all_args

Argument parameters this object depends on.

args

Argument parameters this object directly depends on.

dependencies

Registry of parameters this instance depends on.

dependent

value

Value, evaluated from the values of the other parameters.

Methods Summary

copy(pars)

Create a copy of this instance.

from_json_object(obj, pars)

Build the parameter from a JSON object (a dictionary).

restoring_state()

Enter a context where the attributes of the parameter will be restored on exit.

to_json_object()

Represent this class as a JSON-like object.

Attributes Documentation

all_args

Argument parameters this object depends on.

Type

Registry(Parameter)

args

Argument parameters this object directly depends on.

Type

Registry(Parameter)

dependencies

Registry of parameters this instance depends on.

Type

Registry(Parameter)

dependent = True
value

Value, evaluated from the values of the other parameters.

Type

float

Methods Documentation

copy(pars)[source]

Create a copy of this instance.

Parameters

pars (Registry) – parameter to build the class.

Returns

A copy of this instance.

Return type

Formula

Warning

Avoid calling this method directly for sets of parameters and use the Registry.copy() method instead, so the possible dependencies among parameters are correctly solved.

classmethod from_json_object(obj, pars)[source]

Build the parameter from a JSON object (a dictionary). This is meant to be used together with the json module.

Parameters
  • obj (dict) – object to use to construct the class.

  • pars (Registry) – registry with the parameters this object depends on.

Returns

parameter created from the JSON object.

Return type

Parameter

restoring_state()

Enter a context where the attributes of the parameter will be restored on exit.

to_json_object()[source]

Represent this class as a JSON-like object.

Returns

this class as a JSON-like object.

Return type

dict