Skip to content
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

Don't warn on empty reductions #3811

Closed
max-sixty opened this issue Feb 28, 2020 · 2 comments · Fixed by #4369
Closed

Don't warn on empty reductions #3811

max-sixty opened this issue Feb 28, 2020 · 2 comments · Fixed by #4369

Comments

@max-sixty
Copy link
Collaborator

Numpy warns when computing over an all-NaN slice. We handle that case reasonably and so should handle and discard the warning.

MCVE Code Sample

In [1]: import xarray as xr                                                                                                                                         

In [2]: import numpy as np                                                                                                                                          

In [3]: da = xr.DataArray(np.asarray([np.nan]*3))                                                                                                                   

In [4]: da                                                                                                                                                          
Out[4]: 
<xarray.DataArray (dim_0: 3)>
array([nan, nan, nan])
Dimensions without coordinates: dim_0

In [6]: da.mean()                                                                                                                                                   
[...]/python3.6/site-packages/xarray/core/nanops.py:142: RuntimeWarning: Mean of empty slice
  return np.nanmean(a, axis=axis, dtype=dtype)
Out[6]: 
<xarray.DataArray ()>
array(nan)

Expected Output

No warning

Problem Description

Somewhat discussed in #1164, and #1652, but starting a separate issue as it's more important than just noise in the test suite, and not covered by the existing work on comparisons & arithmetic

Output of xr.show_versions()

@max-sixty
Copy link
Collaborator Author

As discussed in the team meeting, there's consensus these should be silenced!

@keewis
Copy link
Collaborator

keewis commented Feb 21, 2021

should have been closed by #4369

@keewis keewis closed this as completed Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants