diff options
author | Nao Pross <np@0hm.ch> | 2024-03-02 18:59:24 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-03-02 18:59:24 +0100 |
commit | 76b012a7c615da5678bf7e8373bf39010c8bb0b4 (patch) | |
tree | a431c40cfd7be018a7b0cfb8ddd4ac7bebf20b58 | |
parent | Implement missing abstract method Sparse.set_zero (diff) | |
download | mdpoly-76b012a7c615da5678bf7e8373bf39010c8bb0b4.tar.gz mdpoly-76b012a7c615da5678bf7e8373bf39010c8bb0b4.zip |
Fix bug with PolyIndex and Variable.to_repr
Diffstat (limited to '')
-rw-r--r-- | mdpoly/leaves.py | 2 | ||||
-rw-r--r-- | mdpoly/types.py | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/mdpoly/leaves.py b/mdpoly/leaves.py index 4032ead..8a018e6 100644 --- a/mdpoly/leaves.py +++ b/mdpoly/leaves.py @@ -49,7 +49,7 @@ class Var(Leaf, HasRepr): def to_repr(self, repr_type: type[T], state: State) -> T: r = repr_type() - idx = PolyVarIndex(varindex=state.index(self), power=1) + idx = PolyVarIndex.of_var(self, state), r.set(MatrixIndex.scalar, PolyIndex(idx), 1) return r, state diff --git a/mdpoly/types.py b/mdpoly/types.py index a0ea671..0a4c68e 100644 --- a/mdpoly/types.py +++ b/mdpoly/types.py @@ -70,18 +70,18 @@ class PolyVarIndex(NamedTuple): Concretely this represents things like x^2, y^4 """ - varindex: int + var_idx: int # Index in State.variables, not variable! power: Number @classmethod @property def constant(cls): """ Special index for constants, which have no variable """ - return cls(varindex=-1, power=0) + return cls(var_idx=-1, power=0) @classmethod def of_var(cls, variable: Var, state: State, power: Number =1) -> Self: - return cls(varindex=state.index(variable), power=power) + return cls(var_idx=state.index(variable), power=power) class PolyIndex(tuple[PolyVarIndex]): |