summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--polymatrix/expressionstate/mixins.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/polymatrix/expressionstate/mixins.py b/polymatrix/expressionstate/mixins.py
index 9b4817b..f5a0c25 100644
--- a/polymatrix/expressionstate/mixins.py
+++ b/polymatrix/expressionstate/mixins.py
@@ -39,9 +39,16 @@ class ExpressionStateMixin(
if not isinstance(var, Variable):
raise ValueError("State can only index object of type Variable!")
- # Check if already in there
- if var in self.indices.keys():
- return self, self.indices[var]
+ for v, irange in self.indices.items():
+ # Check if already in there
+ if v == var:
+ return self, irange
+
+ # Check that there is not another variable with the same name
+ if v.name == var.name:
+ raise ValueError("Variable must have unique names! "
+ f"There is already a variable named {var.name} "
+ f"with shape {v.shape}")
# If not save new index
size = prod(var.shape)