issues: 383844989
This data as json
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 descriptionWhen 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) <xarray.DataArray (dim_1: 2)> array([ nan, 0.5]) Dimensions without coordinates: dim_1 ``` This confused me because the warning suggests a 0/0 division 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) <xarray.DataArray (dim_1: 2)> array([ nan, 0.5]) Dimensions without coordinates: dim_1
xd.mean(axis=0).compute() array([ nan, 0.5]) ``` Expected OutputEither the warning from a non-chunked DataArray or no warning would be preferred. Output of
|
{ "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 |