diff options
author | Nao Pross <np@0hm.ch> | 2024-05-27 14:44:21 +0200 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-05-27 14:44:21 +0200 |
commit | b0d2a7fa7310261327181d6f64c8eacf451a5733 (patch) | |
tree | 89a736081c20158ec7cbe6c236bc7d7ed7b1a5d2 | |
parent | Fix bug in SubtractionExpr (diff) | |
download | polymatrix-b0d2a7fa7310261327181d6f64c8eacf451a5733.tar.gz polymatrix-b0d2a7fa7310261327181d6f64c8eacf451a5733.zip |
Add missing check for degrees in CombinationsExpr
-rw-r--r-- | polymatrix/expression/mixins/combinationsexprmixin.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/polymatrix/expression/mixins/combinationsexprmixin.py b/polymatrix/expression/mixins/combinationsexprmixin.py index ff2d201..483da96 100644 --- a/polymatrix/expression/mixins/combinationsexprmixin.py +++ b/polymatrix/expression/mixins/combinationsexprmixin.py @@ -1,5 +1,6 @@ import abc import itertools +import math from typing import Iterable from polymatrix.polymatrix.utils import multiply_polynomial @@ -71,7 +72,12 @@ class CombinationsExprMixin(ExpressionBaseMixin): elif isinstance(self.degrees, tuple): degrees = self.degrees - # TODO: check that degrees are all integers + # check that degrees are all integers + for deg in degrees: + if not math.isclose(int(deg), deg): + raise ValueError(f"Non-integer degrees ({deg}) are not supported.") + + degrees = tuple(int(d) for d in degrees) # FIXME: improve error message assert expr_pm.shape[1] == 1 |