[Numpy-discussion] RE: [Numpy-developers] Error behavior. (2)

Paul F. Dubois paul at pfdubois.com
Tue Jul 31 10:18:23 CDT 2001

I understand why some people might want the behavior (return with inf or NaN
etc in arrays rather than get an exception).

Let's ask some basic questions. Having done such an operation, how do I tell
if I have any errant values in the result? For example, what can I compare
x[i] to, in order to know if it is invalid? We have had several requests for
full support of IEEE but nobody knows how to do it portably, as far as I

I resist bringing back fastumath because I wonder if it really would work
portably, I don't know the answers to the simpleest questions like the
above, and if it would I know that it made people reluctant to fix bugs or
add new functions because they would have to do it twice. Adding a new
function already requires something like five different places to fix.

Using optional package MA, a user *can* achieve the goal you desire. For
example, if x and y are numpy arrays, and I want to divide them without
possibility of error, I can do:

z = MA.masked_array(x) / MA.masked_array(y)
if MA.getmask(z) is not None:
     print "Your operation failed in one or more components"

The masked_array constructor does not copy its argument. (MAs mix with
Numerics and scalars, so one of the masked_array calls above could be

More information about the Numpy-discussion mailing list