[SciPy-user] Re: nan puzzle
Grant Edwards
grante at visi.com
Wed Jul 13 12:43:02 EDT 2005
On 2005-07-13, Alan G Isaac <aisaac at american.edu> wrote:
> On Wed, 13 Jul 2005, Grant Edwards apparently wrote:
>> What you probably want to be checking is if x has a nan
>> value, not whether x is the same object as some other
>> object that has a nan value.
>
> How? (See below.)
Here's a function I wrote. There are other implimentations
floating around in various libraries.
def isNaN(f):
u = struct.unpack("L",struct.pack("f",f))[0]
return ((u & 0x7f800000) == 0x7f800000) and (u & 0x7fffff)
> Anyway, now I cannot replicate the problem.
I still don't understand what the problem is (or was).
> Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from scipy import *
>>>> x=nan
>>>> x is nan
> True
>>>> isnan(x)
> 1
>>>> x == nan
> False
>>>> z = [0,1,nan,3]
>>>> z[2] is nan
> True
>>>> x = z[2]
>>>> x is nan
> True
>>>>
OK, I "saw below", but I'm afraid I don't understand what this
is supposed do be showing me.
--
Grant Edwards grante Yow! Sorry, wrong ZIP
at CODE!!
visi.com
More information about the SciPy-User
mailing list