[SciPy-user] Re: nan puzzle
Jim.Vickroy at noaa.gov
Thu Jul 14 09:11:32 CDT 2005
Robert Kern wrote:
> Grant Edwards wrote:
>> On 2005-07-13, Alan G Isaac <aisaac at american.edu> wrote:
>>> Anyway, now I cannot replicate the problem.
>> I still don't understand what the problem is (or was).
> His original code had
> >>> z = [0, 1, nan]
> >>> x = z
> >>> x is nan
> Since "is" evaluates based on pointer comparisons and putting
> something in a list or extracting it again by indexing ought to
> preserve those pointers, that result shouldn't happen for any object,
> nan or otherwise.
> Of course, "x is nan" is a pretty useless operation as you point out,
> and one really should be using some kind of isnan() function.
> Preferably implemented by someone other than one's self. :-)
Sorry, I joined this discussion in mid-stream so I have may have missed
something important, but:
>>> x = [1.0, 2.0, 3.0]
>>> x is 3.0
>>> x == 3.0 # even this is risky
>>> x.append(None) # None is special
>>> x is None
>>> x == None
So without knowing the implementation of nan (e.g., is it truly unique
package-wide), I would not expect x is nan to evalutate to True.
Just my 2-cents worth.
More information about the SciPy-user