[Numpy-discussion] What is the logical value of nan?

Christopher Barker Chris.Barker@noaa....
Wed Mar 11 00:50:24 CDT 2009



Pauli Virtanen wrote:
> Tue, 10 Mar 2009 13:08:17 -0600, Charles R Harris wrote:
>> It isn't 0 so it should be True. Any disagreement?
  - 1
> Nonzero Python object, hence True.

Empty sequences are False also. There was a lot of discussion about all 
this when Guido added Bool types to python. Personally, I don't think 
zero should be false, I think only False (and maybe None) should be 
false -- is it so hard to write: "if x != 0:", rather than "if x:"? but 
there is a LOT of legacy to 0 being False!

Anyway, Laura Creighton wrote a great post about it, with this basic thesis:

 > > Python does not distinguish between True and
 > > False -- Python makes the distinction between something and nothing.

In that context, NaN is nothing, thus False.

my $0.02

-Chris



More information about the Numpy-discussion mailing list