-
-
Notifications
You must be signed in to change notification settings - Fork 12k
Open
Description
As there already exists a mechanism in numpy to manage warnings for possibly anomalous inputs, it seems odd that it doesn't work for all warnings. For example, nanmean raises a warning if given a slice of all nan, and apparently the only way to silence it is to catch it with the python warnings mechanism. np.errstate, despite claiming to handle divide by zero errors, does not:
Python 3.6.2
In [1]: import numpy as np
In [2]: np.__version__
Out[2]: '1.13.1'
In [3]: allnan = np.array([np.nan, np.nan])
In [4]: with np.errstate(divide='ignore', invalid='ignore'):
...: print(np.nanmean(allnan))
...:
/Users/jonathanshor/anaconda2/envs/Python3/bin/ipython:2: RuntimeWarning: Mean of empty slice
if __name__ == '__main__':
nan
I would suggest this could fall under the divide case, but invalid seems plausible as well.
Joelino, fbernhart, renanlarrieu, nepomnyi and b-a0
Metadata
Metadata
Assignees
Labels
No labels