[Numpy-discussion] unexpected behavior of na.where (no short-circuiting)

Sebastian Haase haase at msg.ucsf.edu
Tue Jul 19 21:12:03 CDT 2005


Hi,
any thoughts on this ? I really think it's counter intuitive ?

Thanks,
Sebastian Haase

On Tuesday 05 July 2005 17:34, Sebastian Haase wrote:
> 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
>
>
>
>
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion




More information about the Numpy-discussion mailing list