diff options
author | Nao Pross <np@0hm.ch> | 2024-06-08 14:29:57 +0200 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-06-08 14:29:57 +0200 |
commit | 19e6238c938ece2ea5e1502cdf96aa515d65c313 (patch) | |
tree | 3557738e46e07018d0f12a7aae7f795a307a867b | |
parent | Add more __str__ methods (diff) | |
download | polymatrix-19e6238c938ece2ea5e1502cdf96aa515d65c313.tar.gz polymatrix-19e6238c938ece2ea5e1502cdf96aa515d65c313.zip |
Fix bug in NegationExpr, typo in AffineExpression
-rw-r--r-- | polymatrix/expression/mixins/negationexprmixin.py | 14 | ||||
-rw-r--r-- | polymatrix/polymatrix/mixins.py | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/polymatrix/expression/mixins/negationexprmixin.py b/polymatrix/expression/mixins/negationexprmixin.py index eaaaff3..968022a 100644 --- a/polymatrix/expression/mixins/negationexprmixin.py +++ b/polymatrix/expression/mixins/negationexprmixin.py @@ -23,11 +23,11 @@ class NegationExprMixin(ExpressionBaseMixin): @override def apply(self, state: ExpressionState) -> tuple[ExpressionState, PolyMatrixMixin]: state, u = self.underlying.apply(state) - return state, init_poly_matrix(PolyMatrixDict({ - entry: PolyDict({ - monomial: -coeff - }) - for entry, poly in u.entries() - for monomial, coeff in poly.terms() - }), u.shape) + p = PolyMatrixDict.empty() + for entry, poly in u.entries(): + p[entry] = PolyDict.empty() + for monomial, coeff in poly.terms(): + p[entry][monomial] = -coeff + + return state, init_poly_matrix(p, u.shape) diff --git a/polymatrix/polymatrix/mixins.py b/polymatrix/polymatrix/mixins.py index b35490d..44f1e07 100644 --- a/polymatrix/polymatrix/mixins.py +++ b/polymatrix/polymatrix/mixins.py @@ -555,4 +555,4 @@ class PolyMatrixAsAffineExpressionMixin(PolyMatrixMixin, ABC): at :math:`x`. """ # TODO: If slow consider replacing with toolz.functoolz.curry from ctoolz - return functools.partial(PolyMatrixAsAffineExpression.affine_eval, self) + return functools.partial(PolyMatrixAsAffineExpressionMixin.affine_eval, self) |