diff options
author | Nao Pross <np@0hm.ch> | 2024-03-10 23:42:16 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-03-10 23:42:16 +0100 |
commit | 808143cc2543d04a844bbaefd34b0e2d15c8b977 (patch) | |
tree | 92897d41319ff9443479beacec7c50a15974038a | |
parent | Fix bug in PolyPartialDiff and add PolyRingExpr.diff(wrt) (diff) | |
download | mdpoly-808143cc2543d04a844bbaefd34b0e2d15c8b977.tar.gz mdpoly-808143cc2543d04a844bbaefd34b0e2d15c8b977.zip |
Fix PolyIndex.__contains__
Diffstat (limited to '')
-rw-r--r-- | mdpoly/index.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/mdpoly/index.py b/mdpoly/index.py index 5ff28b6..5211245 100644 --- a/mdpoly/index.py +++ b/mdpoly/index.py @@ -160,8 +160,13 @@ class PolyIndex(tuple[PolyVarIndex]): indices = ", ".join(map(repr, self)) return f"{name}({indices})" - def __contains__(self, var_idx): - return any(map(lambda e: e.var_idx == var_idx, self)) + # FIXME: may need to convert to method to avoid breaking expected behaviour + def __contains__(self, index: PolyVarIndex | int) -> bool: + if isinstance(index, PolyVarIndex): + return tuple.__contains__(self, index) + + if isinstance(index, int): + return any(map(lambda e: e.var_idx == index, self)) # -- Helper methods --- |