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

Sturla Molden sturla@molden...
Wed Mar 11 13:19:01 CDT 2009


Charles R Harris wrote:
>
> Raising exceptions in ufuncs is going to take some work as the inner 
> loops are void functions without any means of indicating an error.  
> Exceptions also need to be thread safe. So I am not opposed but it is 
> something for the future.
>
I just saw David Cournapeau's post regarding a NPY_NAN macro. As it uses 
the IEEE754 binary format, at least NPY_NAN should be True in a boolean 
context. So bool(nan) is True then.

And that's what happens now on my computer as well:

 >>> bool(nan)
True

I don't like Python exception's raised inside ufuncs. In the future we 
NumPy might add OpenMP support to ufuncs (multicore CPUs are getting 
common), and Python exceptions would prevent that, or at least make it 
difficult (cf. the GIL).


S.M.



More information about the Numpy-discussion mailing list