[Numpy-discussion] Unexpected RuntimeWarning

Pauli Virtanen pav@iki...
Fri Nov 23 05:42:12 CST 2012


Bob Dowling <rjd4+numpy <at> cam.ac.uk> writes:
[clip]
> I'm guessing that numpy.where() is evaluating the complete arccos and 
> arccosh arrays and therefore getting invalid arguments.
> 
> Now, I can turn off the warnings with numpy.seterr(invalid='ignore') but 
> that's not what I would regard as good practice.
> 
> Is there a "numpythonic" way to address the issue?

Correct, the arguments are evaluated first, due to how Python semantics work.

You may want to use this:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.piecewise.html



More information about the NumPy-Discussion mailing list