I really want to avoid these annoying numpy warnings since I have to deal with a lot of NaNs
. I know this is usually done with seterr, but for some reason here it does not work:
import numpy as np
data = np.random.random(100000).reshape(10, 100, 100) * np.nan
np.seterr(all="ignore")
np.nanmedian(data, axis=[1, 2])
It gives me a runtime warning even though I set numpy to ignore all errors...any help?
Edit (this is the warning that is recieved):
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numpy/lib/nanfunctions.py:612: RuntimeWarning: All-NaN slice encountered warnings.warn("All-NaN slice encountered", RuntimeWarning)
seterr
like other errors, if some code can handle missing values and there is no straightforward way to not haveAll-NnN
slices (like if it is some sort of downsampling among non-missing values) it should just returnnan
and be quite. – dashesy Jun 13 '15 at 23:56