Commit 45f7d8a7 authored by Tim Keil's avatar Tim Keil

simplify code in functionals.py

Co-authored-by: default avatarStephan Rave <stephanrave@uni-muenster.de>
parent 53bd37ae
......@@ -71,15 +71,14 @@ class ParameterFunctional(ParametricObject):
return LincombParameterFunctional(functionals, coefficients)
def _radd_sub(self, other, sign):
if not isinstance(other, (ParameterFunctional, Number)):
assert not isinstance(other, ParameterFunctional) # handled by __add__/__sub__
if not isinstance(other, Number):
return NotImplemented
if isinstance(other, Number):
if other == 0:
return self
other = ConstantParameterFunctional(other)
if other == 0:
return self
other = ConstantParameterFunctional(other)
# note that 'other' can never be a LincombParameterFunctional
if self.name != 'LincombParameterFunctional' or (self.name == 'LincombParameterFunctional'
and not isinstance(self, LincombParameterFunctional)):
functionals, coefficients = (other, self), (1., sign)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment