summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-06-08 14:29:57 +0200
committerNao Pross <np@0hm.ch>2024-06-08 14:29:57 +0200
commit19e6238c938ece2ea5e1502cdf96aa515d65c313 (patch)
tree3557738e46e07018d0f12a7aae7f795a307a867b
parentAdd more __str__ methods (diff)
downloadpolymatrix-19e6238c938ece2ea5e1502cdf96aa515d65c313.tar.gz
polymatrix-19e6238c938ece2ea5e1502cdf96aa515d65c313.zip
Fix bug in NegationExpr, typo in AffineExpression
Diffstat (limited to '')
-rw-r--r--polymatrix/expression/mixins/negationexprmixin.py14
-rw-r--r--polymatrix/polymatrix/mixins.py2
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)