aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdpoly/state.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/mdpoly/state.py b/mdpoly/state.py
index 739ec7a..6f47964 100644
--- a/mdpoly/state.py
+++ b/mdpoly/state.py
@@ -4,7 +4,7 @@ from dataclasses import dataclass, field
if TYPE_CHECKING:
from .types import Number
- from .leaves import Var, Param
+ from .leaves import Var, Param, Const
Index = int
@@ -30,7 +30,11 @@ class State:
return self.variables[var]
- def from_index(self, index: Index) -> Var:
+ def from_index(self, index: Index) -> Var | Const:
+ if index == -1:
+ from .leaves import Const
+ return Const(value=1, name="1")
+
for var, idx in self.variables.items():
if idx == index:
return var