aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-03-07 23:47:11 +0100
committerNao Pross <np@0hm.ch>2024-03-07 23:47:11 +0100
commitb391bd50e6e995ae5a34a09c3d00fd31a651cd2f (patch)
tree11b21a384fb6c8558f15ff6af0f2c5a64ec80d7f
parentFinish incomplete implementation of MatVar.to_repr (diff)
downloadmdpoly-b391bd50e6e995ae5a34a09c3d00fd31a651cd2f.tar.gz
mdpoly-b391bd50e6e995ae5a34a09c3d00fd31a651cd2f.zip
Fix regression in State.from_index
Likely caused by f69cda1b84482a2c5dd4c6b8fcf16aebb7ac11ba
-rw-r--r--mdpoly/state.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/mdpoly/state.py b/mdpoly/state.py
index 6924146..0095916 100644
--- a/mdpoly/state.py
+++ b/mdpoly/state.py
@@ -3,7 +3,7 @@ from typing import TYPE_CHECKING
from dataclasses import dataclass, field
from .index import PolyVarIndex
-from .abc import Var, Param, Const
+from .abc import Var, Param
if TYPE_CHECKING:
from .index import Number
@@ -35,7 +35,7 @@ class State:
return self.variables[var]
- def from_index(self, index: Index | PolyVarIndex) -> Var | Const:
+ def from_index(self, index: Index | PolyVarIndex) -> Var | Number:
""" Get a variable object from the index.
This is a reverse lookup operation and it is **not**
:math:`\mathcal{O}(1)`!"""
@@ -43,8 +43,7 @@ class State:
index = index.var_idx
if index == -1:
- from .leaves import Const
- return Const(value=1, name="1")
+ return 1
for var, idx in self.variables.items():
if idx == index: