[SciPy-user] Re: nan puzzle
Robert Kern
rkern at ucsd.edu
Thu Jul 14 19:07:01 EDT 2005
Jim Vickroy wrote:
> 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[2]
>> >>> x is nan
>> False
>>
>> 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[2] is 3.0
> False
Float literals like 3.0 creates a new object every time. nan is not a
literal; it is a variable.
--
Robert Kern
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the SciPy-User
mailing list