diff options
Diffstat (limited to '')
-rw-r--r-- | polymatrix/polymatrix/index.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/polymatrix/polymatrix/index.py b/polymatrix/polymatrix/index.py index 79b8161..384feb8 100644 --- a/polymatrix/polymatrix/index.py +++ b/polymatrix/polymatrix/index.py @@ -1,7 +1,8 @@ from __future__ import annotations + from typing import NamedTuple, Iterable, cast from collections import UserDict -from itertools import filterfalse +from itertools import dropwhile # TODO: remove these types, they are here for backward compatiblity MonomialData = tuple[tuple[int, int], ...] @@ -56,9 +57,11 @@ class MonomialIndex(tuple[VariableIndex]): # they have the same degree the index counts if self.degree == other.degree: # Assumes that monomialindex is sorted! - # FIXME: if the first variable is also the same continue until one + # if the first variable is also the same continue until one # finishes or the values differ. - return self[0] < other[0] + # FIXME: check that return value is not none + s, o = next(dropwhile(lambda t: t[0] == t[1], zip(self, other))) + return s < o return self.degree < other.degree @@ -75,7 +78,7 @@ class MonomialIndex(tuple[VariableIndex]): @staticmethod def is_constant(index: MonomialIndex) -> bool: """ Returns true if it is indexing a constant monomial. """ - return len(index) > 1 + return len(index) == 0 @staticmethod def sort(index: MonomialIndex) -> MonomialIndex: |