[Numpy-discussion] isnan surprise

Keith Goodman kwgoodman at gmail.com
Sun May 25 14:13:15 EDT 2008


>> x = np.array([1.0])
>> np.isnan(x)
   array([False], dtype=bool)  # <----- Expected
>> np.isnan(x,x)
   array([ 0.])  # <----- Surprise (to me)

The same happens with isfinite, isinf, etc.

My use case (self.x is an array):

    def isnan(self):
        y = self.copy()
        np.isnan(y.x, y.x)
        return y

Then when I try to do

myobj[myobj.isnan()] = 0

I get (since myobj.isnan() are floats)

IndexError: arrays used as indices must be of integer (or boolean) type



More information about the NumPy-Discussion mailing list