Skip to content

bug: Incompatible with xarray 2026.4.0 — Dataset(Dataset) no longer allowed #650

@FBumann

Description

@FBumann

Description

xarray 2026.4.0 removed the ability to pass a Dataset as data_vars to the Dataset() constructor (xarray GH11095). This was never intended behavior and silently dropped attrs.

linopy uses this pattern in several places:

  • expressions.py:287xr.Dataset(ds.assign_coords(new_coords))
  • expressions.py:395Dataset(data.transpose(..., TERM_DIM))
  • expressions.py:2101xr.Dataset(data.transpose(..., FACTOR_DIM, TERM_DIM))
  • model.py:362Dataset(value) in the parameters setter

All raise TypeError: Passing a Dataset as data_vars to the Dataset constructor is not supported.

How to reproduce

pip install xarray==2026.4.0
python -c "from linopy import Model; Model()"

Expected behavior

linopy should work with the latest xarray release.

Environment

  • linopy: master (36bc106)
  • xarray: 2026.4.0
  • Python: 3.10+

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions