Open
Description
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