From 19e6238c938ece2ea5e1502cdf96aa515d65c313 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sat, 8 Jun 2024 14:29:57 +0200 Subject: Fix bug in NegationExpr, typo in AffineExpression --- polymatrix/expression/mixins/negationexprmixin.py | 14 +++++++------- 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) -- cgit v1.2.1