id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 383844989,MDU6SXNzdWUzODM4NDQ5ODk=,2566,Unexpected warning when taking mean of all-NaN slice in chunked DataArray,30007270,closed,0,,,2,2018-11-23T14:33:00Z,2020-10-24T04:17:32Z,2020-10-24T04:17:32Z,NONE,,,,"#### Problem description When taking the mean of a DataArray with an all-NaN axis, I get the following warning: ``` data = np.array([[np.nan,0],[np.nan,1]]) xc = xr.DataArray(data).chunk() xc.mean('dim_0').compute() /nbhome/xrc/anaconda2/envs/py361/lib/python3.6/site-packages/dask/array/numpy_compat.py:28: RuntimeWarning: invalid value encountered in true_divide x = np.divide(x1, x2, out) array([ nan, 0.5]) Dimensions without coordinates: dim_1 ``` This confused me because the warning suggests a [0/0 division](https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.geterr.html) and/or issues with typecasting. Furthermore, the warning is different when the data is not chunked: ```python x = xr.DataArray(data) x.mean('dim_0') /nbhome/xrc/anaconda2/envs/py361/lib/python3.6/site-packages/xarray/core/nanops.py:161: RuntimeWarning: Mean of empty slice return np.nanmean(a, axis=axis, dtype=dtype) array([ nan, 0.5]) Dimensions without coordinates: dim_1 ``` Also, using pure dask does not raise this warning. ``` xd = da.from_array(data,chunks=(1,1)) xd.mean(axis=0).compute() array([ nan, 0.5]) ``` #### Expected Output Either the warning from a non-chunked DataArray or no warning would be preferred. #### Output of ``xr.show_versions()``
commit: None python: 3.6.6.final.0 python-bits: 64 OS: Linux OS-release: 2.6.32-696.30.1.el6.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US LOCALE: en_US.ISO8859-1 xarray: 0.11.0 pandas: 0.23.4 numpy: 1.13.1 scipy: 0.19.1 netCDF4: 1.3.1 h5netcdf: 0.5.0 h5py: 2.7.1 Nio: None zarr: None cftime: 1.0.2.1 PseudonetCDF: None rasterio: None iris: None bottleneck: 1.2.0 cyordereddict: None dask: 0.20.1 distributed: 1.24.0 matplotlib: 3.0.1 cartopy: 0.16.0 seaborn: 0.8.1 setuptools: 35.0.2 pip: 18.1 conda: None pytest: 3.0.7 IPython: 6.5.0 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2566/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue