-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
xr.merge fails when passing dict #2948
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
Comments
You can pass an iterable of dicts into merge, not a single dict, e.g.,
So I think this is working as expected. |
+1 Though I think for these we should have better error messages. Ideally I think we'd a) check it were an iterable, and b) check each item as processed for one of the valid types, raising with a clear message on failures. Thoughts? |
Yes, absolutely! |
Yes, you are right - I did not take the Would it make sense to pack them? if isinstance(objects, (xr.DataArray, xr.Dataset, dict)):
objects = [objects] Because the alternative is to raise and then the user has to do Then we would need to check |
I'm trying to think through if there would ever be ambiguity between packed and as specified; I think it's fine. One note is that I'm not sure it's that helpful though. In the case listed above, it's just as good to put them in a Dataset: In [2]: xr.merge([objects])
Out[2]:
<xarray.Dataset>
Dimensions: (bar: 1, foo: 2)
Dimensions without coordinates: bar, foo
Data variables:
a (foo) int64 1 2
b (bar) int64 3
In [3]: xr.Dataset(objects)
Out[3]:
<xarray.Dataset>
Dimensions: (bar: 1, foo: 2)
Dimensions without coordinates: bar, foo
Data variables:
a (foo) int64 1 2
b (bar) int64 3 |
Code Sample
Problem description
This returns an
AttributeError
, while the documentation states that a dict is a valid input.Expected Output
Either the docs or the
dict_like_objects
loop should be changed.Output of
xr.show_versions()
xarray: 0.12.1
pandas: 0.24.2
numpy: 1.16.2
scipy: 1.2.1
netCDF4: 1.5.0.1
pydap: None
h5netcdf: 0.7.1
h5py: 2.9.0
Nio: None
zarr: None
cftime: 1.0.3.4
nc_time_axis: 1.2.0
PseudonetCDF: None
rasterio: 1.0.22
cfgrib: 0.9.6.2
iris: 2.2.0
bottleneck: 1.2.1
dask: 1.1.5
distributed: 1.26.1
matplotlib: 3.0.3
cartopy: 0.17.0
seaborn: 0.9.0
setuptools: 41.0.0
pip: 19.0.3
conda: None
pytest: 4.4.0
IPython: 7.4.0
sphinx: 2.0.1
The text was updated successfully, but these errors were encountered: