From: T. C. <al...@an...> - 2004-05-13 11:48:29
|
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 =3D 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=3D1e20 (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=3D=3D0 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... =09 Please.. what am I doing wrong here? --=20 =C1lvaro Tejero Cantero http://alqua.org -- documentos libres free documents |
From: Todd M. <jm...@st...> - 2004-05-13 13:04:13
|
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 <jm...@st...> |
From: T. C. <al...@an...> - 2004-05-13 16:28:01
|
> I think what you're seeing is this: >=20 > where(condition, expression1, expression2) >=20 > Even though condition is selecting parts of expression1 which are valid, > expression1 is still fully evaluated. Is this behaviour what is intended, or do you consider it a shortcoming of the implementation?. In theory avoiding unneeded evaluations of expression1 is very desirable... --=20 =C1lvaro Tejero Cantero http://alqua.org -- documentos libres free documents |
From: Perry G. <pe...@st...> - 2004-05-13 16:59:17
|
Álvaro Tejero Cantero wrote: > > > 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. > > Is this behaviour what is intended, or do you consider it a shortcoming > of the implementation?. In theory avoiding unneeded evaluations of > expression1 is very desirable... > It's about the only way it could work given how an array-based library works (unless there were a mechanism to postpone evaluation of expressions until their context can be determined). The expression is evaluated before it is passed to the where function. Perry Greenfield |
From: Todd M. <jm...@st...> - 2004-05-13 17:01:39
|
On Thu, 2004-05-13 at 12:34, Álvaro Tejero Cantero wrote: > > 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. > > Is this behaviour what is intended, or do you consider it a shortcoming > of the implementation?. In theory avoiding unneeded evaluations of > expression1 is very desirable... This just falls out of Python function call semantics: parameters are evaluated before a function is called. It is a property of Python so I think we're stuck with it. Two things come to mind to get rid of the warnings: 1. Stuff the input arrays with values which avoid the warnings. condition = logical_and(RV<0,discr>0) discr[condition] = 1 VV[condition] = 1 newtimes = where(condition, (-RV-sqrt(discr))/VV, far_future) 2. Use the Error system to suppress the warnings: Error.pushMode(dividebyzero="ignore", invalid="ignore") newtimes = where(logical_and(RV<0,discr>0), (-RV-sqrt(discr))/VV, far_future) Error.popMode() Regards, Todd |
From: T. C. <al...@an...> - 2004-05-13 18:50:02
|
On Thu, 2004-05-13 at 20:40, Paul Dubois wrote: > Use MA, it is designed to solve this problem. Is it as fast as using numarray arrays? Are you aware of example code floating around, apart from the docs? Thank you! --=20 =C1lvaro Tejero Cantero http://alqua.org -- documentos libres free documents |