summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--polymatrix/expression/mixins/quadraticinexprmixin.py7
-rw-r--r--polymatrix/expression/mixins/subtractmonomialsexprmixin.py3
2 files changed, 8 insertions, 2 deletions
diff --git a/polymatrix/expression/mixins/quadraticinexprmixin.py b/polymatrix/expression/mixins/quadraticinexprmixin.py
index 4568286..2b23827 100644
--- a/polymatrix/expression/mixins/quadraticinexprmixin.py
+++ b/polymatrix/expression/mixins/quadraticinexprmixin.py
@@ -41,7 +41,12 @@ class QuadraticInExprMixin(ExpressionBaseMixin):
terms = collections.defaultdict(lambda: collections.defaultdict(float))
- for monomial, value in underlying.get_poly(0, 0).items():
+ underlying_poly = underlying.get_poly(0, 0)
+
+ if underlying_poly is None:
+ raise Exception(f'{self.underlying} is empty')
+
+ for monomial, value in underlying_poly.items():
x_monomial = tuple((var_idx, count) for var_idx, count in monomial if var_idx in variable_indices)
p_monomial = tuple((var_idx, count) for var_idx, count in monomial if var_idx not in variable_indices)
diff --git a/polymatrix/expression/mixins/subtractmonomialsexprmixin.py b/polymatrix/expression/mixins/subtractmonomialsexprmixin.py
index d5091c6..09f71b1 100644
--- a/polymatrix/expression/mixins/subtractmonomialsexprmixin.py
+++ b/polymatrix/expression/mixins/subtractmonomialsexprmixin.py
@@ -37,7 +37,8 @@ class SubtractMonomialsExprMixin(ExpressionBaseMixin):
try:
remainder = subtract_monomial_indices(m1, m2)
except SubtractError:
- continue
+ # continue
+ remainder = tuple()
yield remainder