Weird behavior (bug??) in numpy. Contrary to the docs, the following code gives a RuntimeWarning: invalid value encountered in fmax
a = np.random.uniform(0.1, 0.4, (5, 5))
b = np.random.uniform(0, 3.5, (5, 5))
b[0, 0] = np.nan
c = np.fmax(a, b) # Same problem with c = np.maximum(a, b)
I'm stuck as I need these NaNs in my arrays and now my functions stop in iPython with this damn warning (ok, they really don't stop but it's rather annoying)
EDIT:
numpy 1.6.1
ipython 0.13.1
I get the same issue as well. These warnings are an intentional aspect of numpy, to inform users when they may be running up against some limitations of the framework. The value of c
is still returned in the above code, so it's working fine.
If you don't want to see these specific errors anymore, just modify numpy's warning settings as you wish with:
np.seterr(invalid='ignore')
And you won't see invalid value warnings anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With