Commit f8078ac3 authored by Stephan Rave's avatar Stephan Rave
Browse files

[ProductParameterFunctional] keep order of factors and use tuple

parent 4fc3893a
Pipeline #65088 passed with stages
in 49 minutes and 6 seconds
......@@ -103,14 +103,14 @@ class ParameterFunctional(ParametricObject):
return NotImplemented
if self.name != 'ProductParameterFunctional' or not isinstance(self, ProductParameterFunctional):
if isinstance(other, ProductParameterFunctional) and other.name == 'ProductParameterFunctional':
return other.with_(factors=other.factors + [self])
return other.with_(factors=(self,) + other.factors)
else:
return ProductParameterFunctional([self, other])
return ProductParameterFunctional((self, other))
elif isinstance(other, ProductParameterFunctional) and other.name == 'ProductParameterFunctional':
factors = self.factors + other.factors
return ProductParameterFunctional(factors)
else:
return self.with_(factors=self.factors + [other])
return self.with_(factors=self.factors + (other,))
__rmul__ = __mul__
......@@ -328,6 +328,7 @@ class ProductParameterFunctional(ParameterFunctional):
def __init__(self, factors, name=None):
assert len(factors) > 0
assert all(isinstance(f, (ParameterFunctional, Number)) for f in factors)
factors = tuple(factors)
self.__auto_init(locals())
def evaluate(self, mu=None):
......@@ -352,7 +353,6 @@ class ProductParameterFunctional(ParameterFunctional):
return LincombParameterFunctional(summands, [1] * len(summands), name=f'{self.name}_d_{parameter}_{index}')
class ConjugateParameterFunctional(ParameterFunctional):
"""Conjugate of a given |ParameterFunctional|
......
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