linopy
linopy copied to clipboard
linopy incompatible to xarray 2025.7.0
Version Checks (indicate both or one)
-
[x] I have confirmed this bug exists on the lastest release of Linopy.
-
[x] I have confirmed this bug exists on the current
masterbranch of Linopy.pip install git+https://github.com/PyPSA/linopy.git
Issue Description
Hi, just to track this issue:
I get the following error when using xarray 2025.7.0 with linopy and pypsa. With xarray 2025.6.1 everything works fine.
ValueError: Added data contains non-customized dimension names. This is not allowed when setting
force_dim_namesto True.
The full stacktrace of my call:
assume -s example_01d from https://github.com/assume-framework/assume
File "/home/maurer/fh-gitlab/projects/ASSUME/assume/markets/base_market.py", line 633, in clear_market
(accepted_orderbook, rejected_orderbook, market_meta, flows) = self.clear(
^^^^^^^^^^^
File "/home/maurer/fh-gitlab/projects/ASSUME/assume/markets/clearing_algorithms/redispatch.py", line 195, in clear
status, termination_condition = redispatch_network.optimize(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/maurer/.conda/envs/assume-joss3/lib/python3.12/site-packages/pypsa/optimization/optimize.py", line 628, in __call__
return optimize(self.n, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/maurer/.conda/envs/assume-joss3/lib/python3.12/site-packages/pypsa/optimization/optimize.py", line 590, in optimize
m = create_model(
^^^^^^^^^^^^^
File "/home/maurer/.conda/envs/assume-joss3/lib/python3.12/site-packages/pypsa/optimization/optimize.py", line 293, in create_model
define_nodal_balance_constraints(
File "/home/maurer/.conda/envs/assume-joss3/lib/python3.12/site-packages/pypsa/optimization/constraints.py", line 622, in define_nodal_balance_constraints
n.model.add_constraints(lhs, "=", rhs, name=f"Bus{suffix}-nodal_balance", mask=mask)
File "/home/maurer/.conda/envs/assume-joss3/lib/python3.12/site-packages/linopy/model.py", line 666, in add_constraints
self.check_force_dim_names(data)
File "/home/maurer/.conda/envs/assume-joss3/lib/python3.12/site-packages/linopy/model.py", line 384, in check_force_dim_names
raise ValueError(
ValueError: Added data contains non-customized dimension names. This is not allowed when setting `force_dim_names` to True.
I will try to track the root cause of this issue by creating a minimal non-working example, but I wanted to create this issue just now to track this error.
Reproducible Example
`assume -s example_01d` from https://github.com/assume-framework/assume
Expected Behavior
should not raise error as working before with xarray v2025.6.1
Installed Versions
argcomplete==3.6.2
babel==2.16.0
Bottleneck==1.5.0
certifi==2025.6.15
cftime==1.6.4.post1
click==8.2.1
cloudpickle==3.1.1
codespell==2.3.0
contourpy==1.3.2
cycler==0.12.1
dask==2025.5.1
deprecation==2.1.0
dill==0.4.0
docutils==0.21.2
fonttools==4.58.5
fsspec==2025.5.1
geopandas==1.1.1
greenlet==3.2.3
highspy==1.11.0
imagesize==1.4.1
kiwisolver==1.4.8
linopy==0.5.5
locket==1.0.0
mango-agents==2.1.5
MarkupSafe==3.0.2
matplotlib==3.10.3
nest-asyncio==1.6.0
netCDF4==1.7.2
networkx==3.5
numexpr==2.11.0
numpy==2.3.1
packaging==25.0
paho-mqtt==2.1.0
pandas==2.3.0
partd==1.4.2
pillow==11.3.0
ply==3.11
polars==1.31.0
protobuf==5.27.2
psycopg2-binary==2.9.10
Pygments==2.18.0
pyogrio==0.11.0
pyomo==6.9.2
pyparsing==3.2.3
pyproj==3.7.1
pypsa==0.32.2
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.2
tqdm==4.67.1
typing_extensions==4.14.1
tzdata==2025.2
validators==0.35.0
wheel==0.45.1
xarray==2025.7.0
Thank you! I added a pin in PyPSA for now https://github.com/PyPSA/PyPSA/pull/1274
Great! Glad, that there is a test failing as a MWE already, so I don't have to extract one.