`Parameter`s don't support some math operations
from finesse.script import parse
model = parse("l l1")
model.l1.P**2
works, but
from finesse.script import parse
model = parse("l l1")
2**model.l1.P
raises
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In [1], line 3
1 from finesse.script import parse
2 model = parse("l l1")
----> 3 2**model.l1.P
File src/finesse/parameter.pyx:581, in finesse.parameter.Parameter.__pow__()
AttributeError: 'int' object has no attribute 'value'
Similarly %
fails with a parameter on either side.
This can probably be fixed by adding __rpow__
, __mod__
and __rmod__
to the Parameter
class in parameter.pyx
.
Then ´Parameter
would support all standard operations (+
, -
, *
, /
, **
, %
).
We might also want to add a __trunc__
method, this would enable using all functions of the math
package.