diff options
author | Nao Pross <np@0hm.ch> | 2024-03-06 18:42:23 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-03-06 18:42:23 +0100 |
commit | 0c10239db7b4cd83ec523953cba0ff7fd0057c2c (patch) | |
tree | 2a9cacf0538c56e65c2127c561dcf27285b30549 | |
parent | Move to_repr to Expr.to_repr necessary by removing duck typing HasRepr (diff) | |
download | mdpoly-0c10239db7b4cd83ec523953cba0ff7fd0057c2c.tar.gz mdpoly-0c10239db7b4cd83ec523953cba0ff7fd0057c2c.zip |
Fix missing case for PolyIndex.differentiate
-rw-r--r-- | mdpoly/index.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/mdpoly/index.py b/mdpoly/index.py index 2837a46..02318a4 100644 --- a/mdpoly/index.py +++ b/mdpoly/index.py @@ -148,6 +148,9 @@ 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)) + @classmethod def from_dict(cls, d) -> Self: """ Construct an index froma dictionary, where the keys are the @@ -209,6 +212,9 @@ class PolyIndex(tuple[PolyVarIndex]): if cls.is_constant(index): return None + if wrt not in index: + return None + def is_wrt_var(idx: PolyVarIndex) -> bool: return idx.var_idx == wrt |