Skip to content
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

Make compat="override" more strict. #10094

Open
dcherian opened this issue Mar 3, 2025 · 0 comments
Open

Make compat="override" more strict. #10094

dcherian opened this issue Mar 3, 2025 · 0 comments
Labels
bug topic-combine combine/concat/merge

Comments

@dcherian
Copy link
Contributor

dcherian commented Mar 3, 2025

What happened?

The compat="override" option in the various combining functions, avoids comparing values for compatibility and simply picks the first occurence of a variable, and inserts it in the result.

This can be dangerous if the values are of differing dimensionality:

ds1 = xr.Dataset({"x": 0})
ds2 = xr.Dataset({"x": ("y", [0, 0])})

Now the dimensionality of x in the output depends on the order of arguments (example below).

I propose that compat="override" at least check that ndim is the same for a variable across all provided objects.

Example

xr.merge([ds1, ds2], compat="override")
<xarray.Dataset> Size: 8B
Dimensions:  ()
Data variables:
    x        int64 8B 0
xr.merge([ds2, ds1], compat="override")
<xarray.Dataset> Size: 16B
Dimensions:  (y: 2)
Dimensions without coordinates: y
Data variables:
    x        (y) int64 16B 0 0
@dcherian dcherian added bug needs triage Issue that has not been reviewed by xarray team member labels Mar 3, 2025
@dcherian dcherian added topic-combine combine/concat/merge and removed needs triage Issue that has not been reviewed by xarray team member labels Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug topic-combine combine/concat/merge
Projects
None yet
Development

No branches or pull requests

1 participant