[Numpy-discussion] What is the logical value of nan?
Charles R Harris
Wed Mar 11 13:36:58 CDT 2009
On Wed, Mar 11, 2009 at 12:19 PM, Sturla Molden <email@example.com> wrote:
> 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)
> 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).
I think numpy needs someway to raise these errors, but error handling is
always tricky. Do you have any suggestions as to how you would like to do
it? I was thinking that adding an int return to the loops would provide some
way of indicating errors without specifying how they were to be handled at
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion