[Numpy-discussion] np.nan and ``is``

Alan G Isaac aisaac@american....
Fri Sep 19 12:34:51 CDT 2008

 > On Fri, Sep 19, 2008 at 1:59 PM, Alan G Isaac <aisaac@american.edu> wrote:
 >> Might someone explain this to me?
 >>     >>> x = [1.,np.nan]
 >>     >>> np.nan in x
 >>     True
 >>     >>> np.nan in np.array(x)
 >>     False
 >>     >>> np.nan in np.array(x).tolist()
 >>     False
 >>     >>> np.nan is float(np.nan)
 >>     True

On 9/19/2008 1:15 PM Lisandro Dalcin apparently wrote:
> I do not remember right now the implementations of comparisons in core
> Python, but I believe the 'in' operator is testing first for object
> identity, and then 'np.nan in [np.nan]' then returns True, and then
> the fact that 'np.nan==np.nan' returns False is never considered.

Sure.  All evaluations to True make sense to me.
I am asking about the ones that evaluate to False.

More information about the Numpy-discussion mailing list