-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
decode_cf called on mfdataset throws error: 'Array' object has no attribute 'tolist' #3215
Comments
I'm having the same issue with xarray 0.12.3, numpy 1.17.0, python 3.7.3. |
I think this is being thrown by dask, here is an even more minimal example: >>> import dask as da
>>> da.array.from_array([]).tolist()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Array' object has no attribute 'tolist' |
Seems that this is by design, from here
So I still don't understand why it fails when |
This is definitely due to NumPy 1.17 / I think the right fix is to add explicit casting to NumPy, e.g., |
A short term work around is to set the environment variable |
Thanks @shoyer. I still don't understand the different code paths between |
In the first case, CF conventions decoding is done on xarray's internal lazy BackendArray objects. In the second case, CF conventions decoding is done on dask arrays. There are a few cases where this can be slower / require loading more data to look at a small slice of array data. |
Thanks for the explanation. |
Confirmed that Have submitted a PR with your suggested fix #3220 Confirmed the submitted code fixes my issue. |
MCVE Code Sample
Expected Output
Nothing
Problem Description
When opening data with
open_mfdataset
callingdecode_cf
throws an error, when called as a separate step, but works as part of theopen_mfdataset
call.Error is:
Output of
xr.show_versions()
xarray: 0.12.1
pandas: 0.25.0
numpy: 1.17.0
scipy: 1.2.1
netCDF4: 1.5.1.2
pydap: installed
h5netcdf: 0.7.4
h5py: 2.9.0
Nio: 1.5.5
zarr: 2.3.2
cftime: 1.0.3.4
nc_time_axis: 1.2.0
PseudonetCDF: None
rasterio: None
cfgrib: 0.9.7.1
iris: 2.2.1dev0
bottleneck: 1.2.1
dask: 2.2.0
distributed: 2.2.0
matplotlib: 2.2.4
cartopy: 0.17.0
seaborn: 0.9.0
setuptools: 41.0.1
pip: 19.1.1
conda: installed
pytest: 5.0.1
IPython: 7.7.0
sphinx: None
There is no error using an older version of
numpy
with the samexarray
version:xarray: 0.12.1
pandas: 0.24.2
numpy: 1.16.4
scipy: 1.2.1
netCDF4: 1.5.1.2
pydap: installed
h5netcdf: 0.7.4
h5py: 2.9.0
Nio: None
zarr: 2.3.2
cftime: 1.0.3.4
nc_time_axis: 1.2.0
PseudonetCDF: None
rasterio: None
cfgrib: 0.9.7
iris: 2.2.1dev0
bottleneck: 1.2.1
dask: 1.2.2
distributed: 1.28.1
matplotlib: 2.2.3
cartopy: 0.17.0
seaborn: 0.9.0
setuptools: 41.0.1
pip: 19.1.1
conda: installed
pytest: 4.6.3
IPython: 7.5.0
sphinx: None
Looks like the
tollst()
method has disappeared from something, but even in the debugger it isn't obvious to me exactly why this is happening. I can calllist
onnp.ravel(array[indexer])
at the same point and it works.The netcdf file I am using can be recreated from this CDL dump
The text was updated successfully, but these errors were encountered: