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 857301324,MDU6SXNzdWU4NTczMDEzMjQ=,5151,"DataArray.mean() emits warning with Dask, not NumPy",1312546,closed,0,,,3,2021-04-13T20:34:56Z,2021-09-15T16:41:43Z,2021-09-15T16:41:43Z,MEMBER,,,," **What happened**: When calling DataArray.mean on an all-NaN dataset, a warning is emitted if and only if a Dask array is used. **What you expected to happen**: Identical behavior between the two, probably no warning . **Minimal Complete Verifiable Example**: ```python In [7]: import xarray as xr In [8]: import numpy as np In [9]: import dask.array as da In [10]: import xarray as xr In [11]: a = xr.DataArray(da.from_array(np.full((10, 10), np.nan))) In [12]: a.mean(dim=""dim_0"").compute() /home/taugspurger/miniconda3/envs/tmp-adlfs/lib/python3.8/site-packages/dask/array/numpy_compat.py:39: RuntimeWarning: invalid value encountered in true_divide x = np.divide(x1, x2, out) Out[12]: array([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan]) Dimensions without coordinates: dim_1 In [13]: a.compute().mean(dim=""dim_0"") Out[13]: array([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan]) Dimensions without coordinates: dim_1 ``` **Anything else we need to know?**: I haven't looked closely at why this is happening (I couldn't immediately find where `.mean` is reduced). I know that Dask has had some issues in the past where NumPy warnings filters are set during *graph construction* time, but aren't set when the graph is actually computed. **Environment**:
``` INSTALLED VERSIONS ------------------ commit: None python: 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 16:22:27) [GCC 9.3.0] python-bits: 64 OS: Linux OS-release: 5.4.72-microsoft-standard-WSL2 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: C.UTF-8 LOCALE: en_US.UTF-8 libhdf5: None libnetcdf: None xarray: 0.17.0 pandas: 1.2.4 numpy: 1.20.2 scipy: None netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: 2.7.0 cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2021.04.0 distributed: 2021.04.0 matplotlib: None cartopy: None seaborn: None numbagg: None pint: None setuptools: 52.0.0.post20210125 pip: 21.0.1 conda: None pytest: None IPython: 7.22.0 sphinx: None ```
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5151/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue