From b0d2a7fa7310261327181d6f64c8eacf451a5733 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Mon, 27 May 2024 14:44:21 +0200 Subject: Add missing check for degrees in CombinationsExpr --- polymatrix/expression/mixins/combinationsexprmixin.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- cgit v1.2.1