Formulas
It is possible to specify mathematical formulas as parameter values for the parameter types Integer
, Number
and PhysicalQuantity
.
The formula syntax is different for each parameter type.
- For
Integer
it allows any kind of mathematical expressions in Python syntax (including parentheses) (e.g.2 + 3*4
). - For
Number
it allows any kind of mathematical expressions in Python syntax (including parentheses) as well as functions and constants defined bynumpy
(e.g.(2 + 3) * 4 * sin(pi / 4)
). - For
PhysicalQuantity
it allows the syntax ofNumber
and we can refer to any constants defined in scipy.constants.physical_constants via{name of constant}
(e.g.{electron mass energy equivalent in MeV} * {speed of light in vacuum}**2
).
By default the formula syntax for parameters is activated. You can deactivate by setting e.g. Integer.formulas = False
. If you want to deactivate it for a specific parameter only, just use Integer(formulas=False)
. You can even restrict the formula syntax more by providing a regular expression to formulas
which will be used to match the specification. If for example you only want to allow addition for integers then you could use Integer(pattern=r'[\d+\s]+')
.
Edited by Dominik Vilsmeier