Deltares / xugrid

Xarray and unstructured grids
https://deltares.github.io/xugrid/
MIT License
53 stars 8 forks source link

Use of `set` to test uniqueness of grids in `wrap_func_objects` results in unwanted behavior. #206

Closed JoerivanEngelen closed 5 months ago

JoerivanEngelen commented 5 months ago

To create a list of unique grids, set is used https://github.com/Deltares/xugrid/blob/e74fbc1ef44da0596499476ae4b7309e2ab37c99/xugrid/core/common.py#L101

However, this tests if grids refer to the same object, which results in behaviour like this:

import xugrid as xu

a = xu.data.disk()
grids = xu.concat([a, a], dim="foo").grids
print(len(grids)) # prints 1

grids2= xu.concat([xu.data.disk(), xu.data.disk()], dim="foo").grids
print(len(grids)) # prints 2

We want to test if grids are equal, as to be fixed in this issue: https://github.com/Deltares/xugrid/issues/205

Huite commented 5 months ago

Adding to some of the things in #205 If objects are equal, but not exactly (i.e. one has a celltree initialized, but the other doesn't), in general you'd want the richer object. But there's no clear definition of that, so I'd say: just take the first if there's many.