-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xugrid.merge does not support merging list of dicts wheares xarray.merge does #179
Comments
Is it really that hard to support this? How does xarray do the merging here? I guess it just dispatches on type as well? We can special case the merge implementation (and let it call the wrapped method internally). I think the biggest risk is having it misfire and give confusing errors or something. You wouldn't want to change the wrapping function, because the types only make sense for the merge. |
It appears xarray forces everything to dict-like objects https://github.com/pydata/xarray/blob/main/xarray/core/merge.py#L994 (So either datasets or dicts), then calls Btw, until this is resolved, the workaround for any user running into this issue is to do: import xugrid as xu
uda = xu.data.elevation_nl()
uds_ls = [uda.to_dataset(name = "a"), uda.to_dataset(name = "b")]
uds = xu.merge(uds_ls)
This only appears to be used to wrap xr.concat and xr.merge. So might be possible? |
Fix #708 The changeset is incomplete, as it is not rolled out for all packages yet. Therefore tests will fail, hence the draft status. This to make the review process more focused, reviewers are asked to provide feedback on the approach. Changes: - Variable names are inferred based on what is provided to locals(). This makes it possible to avoid having to manually assign variables in the __init__ of each specific package. - I had to add one function to work around this issue: Deltares/xugrid#179 - Grids are merged with an exact join, this to avoid that xarray joins variable coordinates in an unwanted way when dataarrays are inconsistent, which causes issues like #674 - Refactored the riv unit tests to use pytest cases, so that tests (without the xr.merge) are run for both unstructured and structured data. Update: - Variable names are not inferred with locals() anymore, but instead with a ``pkg_init`` decorator.
A feature I often use in xarray to construct a dataset is by merging a dictionary of DataArrays.
(Note that the dictionary needs to be in a list, to allow multiple dictionaries to be merged as well)
MWE:
In xugrid, however, this fails in the type checking:
Throws:
If it is difficult to support this (the generic typechecker for wrapped xarray functions seems quite neat), it would be good to either document that this goes unsupported somewhere and to document some workarounds.
The text was updated successfully, but these errors were encountered: