-
Notifications
You must be signed in to change notification settings - Fork 62
Closed
Description
When I name a coordinate "sign", an error is raised when I try to create an constraint.
Here a short example to reproduce the issue:
import pandas as pd
import linopy
coords = [pd.Index(range(10), name="sign")]
m = linopy.Model()
x = m.add_variables(lower=0, coords=coords, name="x")
x>=0
Error message:
File ~/.env/lib/python3.10/site-packages/linopy/constraints.py:295, in __repr__(self)
293 else:
294 line = f"{print_coord(coord)}: None"
--> 295 lines.append(line)
296 lines = align_lines_by_delimiter(lines, list(SIGNS_pretty.values()))
298 shape_str = ", ".join(f"{d}: {s}" for d, s in zip(dims, dim_sizes))
KeyError: 0
When I add at least one additional coordinate to coords
, a different error is raised:
File ~/.env/lib/python3.10/site-packages/linopy/constraints.py:295, in __repr__(self)
293 else:
294 line = f"{print_coord(coord)}: None"
--> 295 lines.append(line)
296 lines = align_lines_by_delimiter(lines, list(SIGNS_pretty.values()))
298 shape_str = ", ".join(f"{d}: {s}" for d, s in zip(dims, dim_sizes))
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed
I was able to reproduce some (different) errors for the names: "labels", "coeffs", "vars", "rhs". I found these in constraint.py
in line 671:
dataset_attrs = ["labels", "coeffs", "vars", "sign", "rhs"]
Metadata
Metadata
Assignees
Labels
No labels