[Numpy-discussion] Any and all NaNs
Keith Goodman
kwgoodman at gmail.com
Fri May 23 13:16:53 EDT 2008
I'm writing unit tests for a module that contains matrices. I was
surprised that these are True:
>> import numpy.matlib as mp
>> x = mp.matrix([[mp.nan]])
>> x.any()
True
>> x.all()
True
My use case is (x == y).all() where x and y are the same matrix except
that x contains one NaN. Certianly x and y are not equal.
>> x = mp.asmatrix(range(4)).reshape(2,2)
>> y = mp.asmatrix(range(4)).reshape(2,2)
>> x[0,0] = mp.nan
>> (x == y).all()
True
More information about the NumPy-Discussion
mailing list