[Numpy-discussion] unexpected behavior of na.where (no short-circuiting)
Sebastian Haase
haase at msg.ucsf.edu
Tue Jul 5 17:37:01 EDT 2005
Hi,
I was very surprised when I got this warning:
>>> a = na.arange(4)-2
>>> na.where(a != 0,1./a, 999)
Warning: Encountered divide by zero(s) in divide
[ -0.5 -1. 999. 1. ]
Then I realized that this is generally referred to as (not) "short
circuiting" (e.g. in the case of the '?:'-C-operator, the middle part never
gets evaluated at all if the first part evals to 0 )
Especially annoying was this because (for debugging) I had set this
error-mode:
>>> na.Error.setMode(dividebyzero="error")
My questions are:
a) Did other people encounter this problem ?
b) What is the general feeling about this actually being a "problem" ?
c) Could this (at all possible) be implemented differently ?
Thanks,
Sebastian Haase
More information about the NumPy-Discussion
mailing list