From: Stefan v. d. W. <st...@su...> - 2006-11-11 20:39:04
|
On Sat, Nov 11, 2006 at 10:40:22AM -0800, Keith Goodman wrote: > I accidentally wrote a unit test using int32 instead of float64 and > ran into this problem: >=20 > >> x =3D M.matrix([[1, 2, 3]]) > >> x[0,1] =3D M.nan > >> x > matrix([[1, 0, 3]]) <--- Got 0 instead of NaN >=20 > But this, of course, works: >=20 > >> x =3D M.matrix([[1.0, 2.0, 3.0]]) > >> x[0,1] =3D M.nan > >> x > matrix([[ 1. , nan, 3. ]]) >=20 > Is returning a 0 instead of NaN the expected behavior? NaN (or inf) is a floating point number, so seeing a zero in integer representation seems correct: In [2]: int(N.nan) Out[2]: 0L Cheers St=E9fan |