[Numpy-discussion] Unexpected warnings in where
Todd Miller
jmiller at stsci.edu
Thu May 13 06:06:00 CDT 2004
On Thu, 2004-05-13 at 07:54, Álvaro Tejero Cantero wrote:
> Hi,
>
> I cannot understand why I do receive these warnings:
>
> Warning: Encountered invalid numeric result(s) in sqrt
> Warning: Encountered invalid numeric result(s) in divide
>
> after
>
> >>> newtimes = where(logical_and(RV<0,discr>0), (-RV-sqrt(discr))/VV, far_future)
>
>
> RV, discr, RR, VV are NxN arrays of reals (Float64), while
> far_future=1e20 (scalar).
>
> 1. sqrt(<0) should be impossible, since it's explicitly ruled out that
> discr<0 in the where condition.
>
> 2. /0 should also be impossible, since VV==0 is True only for the
> diagonal...
>
> I've done some testing and where(logical_and(RV<0, discr>0), discr, 666)
> doesn't show any negative numbers, neither does
> where(logical_and(RV<0,discr>0),VV,666) show any zeroes...
>
>
>
> Please.. what am I doing wrong here?
I think what you're seeing is this:
where(condition, expression1, expression2)
Even though condition is selecting parts of expression1 which are valid,
expression1 is still fully evaluated.
Regards,
Todd
--
Todd Miller <jmiller at stsci.edu>
More information about the Numpy-discussion
mailing list