[Numpy-discussion] Power domain (was Re: bug in oldnumeric.ma)

Anne Archibald peridot.faceted at gmail.com
Sat May 10 00:44:57 EDT 2008


2008/5/9 Eric Firing <efiring at hawaii.edu>:

> It seems like some strategic re-thinking may be needed in the long run,
> if not immediately.  There is a wide range of combinations of arguments
> that will trigger invalid results, whether Inf or NaN.  The only way to
> trap and mask all of these is to use masked_invalid after the
> calculation, and this only works if the user has not disabled nan
> output.  I have not checked recently, but based on earlier strategy
> discussions, I suspect that numpy.ma is already strongly depending on
> the availability of nan and inf output to prevent exceptions being
> raised upon invalid calculations.  Maybe this should simply be
> considered a requirement for the use of ma.

I think in principle the right answer is to simply run whatever
underlying function, and mask any NaNs or Infs in the output. This may
be a problem when it comes to seterr - is the behaviour of seterr()
even defined in a multithreaded context? Can it be made thread-local?
Surely hardware must support thread-local floating-point error flags.
If seterr() works this way, then surely the right answer in ma is to
use a try/finally block to turn off exceptions and warnings, and clean
up NaNs after the fact.

Anne



More information about the NumPy-Discussion mailing list