No subject

Thu Nov 16 16:52:29 CST 2006

>>> print x/y
[  1.#INF0000e+000,  2.00000000e+000,  1.50000000e+000,  1.33333333e+000,]
>>> print MA.masked_array(x)/y
[-- ,2.0 ,1.5 ,1.33333333333 ,]
>>> >>> print MA.sqrt(y-2.)
[-- ,-- ,0.0 ,1.0 ,]

I realize this isn't exactly what you had in mind, and it is more expensive
than just letting it rip, but it is reliable and portable. With the infs and
Nans, I'm not sure what you can do with the answer other than print it. It
does place the burden on the programmer to distinguish cases where he wants
to survive a divide by zero from those where he does not, but in my mind
that is a good thing.


More information about the Numpy-discussion mailing list