summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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)