Skip to content

[Bug] - HorizontalFlowBarrierBase.__repr__ fails with xarray=2025.4.0 #1522

Closed
@JoerivanEngelen

Description

@JoerivanEngelen

Bug description
I updated the pixi toml to xarray 2025.4.0 and some instances in the package sanity checks started to fail in the repr tests. Turned out these were the three HorizontalFlowBarrier instances we have in the tests. It turns out including the shapely line data in the dataset resulted (yet again) in an issue with xarray. The error is caused because it cannot compute an nbytes on the xr.Variable if it is an object array for some reason.

To reproduce

  • Update pixi.toml to xarray >=2025.4.0
  • Try to print a HorizontalFlowBarrier instance, or run the package sanity tests.

I can think of two possible solutions:

  1. Similar approach to how we override deepcopy: Override __repr__ (and _repr_html_), in this method first separate shapely data, put that into geodataframe, print the geodataframe separately followed by the leftover options in the xr.Dataset.
  2. See if we can include the shapely data slightly differently in the Dataset, so that representing it works again.

The downside of 1. is that it gives the impression that the shapely line data is not included in the dataset, while it is.

The downside of 2. is that it might break again after an xarray update.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions