Deltares / xugrid

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

identicalness for hydromt_delft3dfm #219

Open veenstrajelmer opened 4 months ago

veenstrajelmer commented 4 months ago

Related to https://github.com/Deltares/hydromt_delft3dfm/issues/128

xugrid/ugrid/ugridbase.py >> equals has changed from 0.8.1 to 0.9.0 causes errors when adding ugriddatararray to existing ugriddataset if not equal

xugrid/ugrid/ugridbase.py

0.8.1:

    def equals(self, other):
        if not isinstance(other, type(self)):
            return False
        # TODO: check values, etc.
        return True

0.9.0:

    def equals(self, other) -> bool:
        if other is self:
            return True
        elif isinstance(other, type(self)):
            xr_self = self.to_dataset()
            xr_other = other.to_dataset()
            return xr_self.identical(xr_other)
        return False
Huite commented 4 months ago

We needed to compare grids in imod-python, what exactly is going wrong?

There's a not a lot of info in the linked issue.

veenstrajelmer commented 4 months ago

@xldeltares and I created this grid on a Friday afternoon before a holiday. The description is a bit meager I agree, but will be updated once we know more. Something happened in hydromt_delft3dfm when adding a UgridArray (variable) to an existing UgridDataset. The UgridArray did not have all dimensions that the UgridDataset has, so we created a xugrid branch/PR with the old compare function to test if it worked. This was the case, but three xugrid testcases failed and further investigation is necessary on our side. This is the related issue, but it also lacks description for now: https://github.com/Deltares/hydromt_delft3dfm/issues/128. An update will follow in a few weeks.