[Numpy-discussion] Should abs([nan]) be supported?
ondrej.certik at gmail.com
Tue Sep 4 23:49:14 EDT 2012
On Tue, Sep 4, 2012 at 8:38 PM, Travis Oliphant <travis at continuum.io> wrote:
> There is an error context that controls how floating point signals are handled. There is a separate control for underflow, overflow, divide by zero, and invalid. IIRC, it was decided on this list a while ago to make the default ignore for underflow and warning for overflow, invalid and divide by zero.
> However, an oversight pushed versions of NumPy where all the error handlers where set to "ignore" and this test was probably written then. I think the test should be changed to check for RuntimeWarning on some of the cases. This might take a little work as it looks like the code uses generators across multiple tests and would have to be changed to handle expecting warnings.
> Alternatively, the error context can be set before the test runs and then restored afterwords:
> olderr = np.seterr(invalid='ignore')
> or, using an errstate context ---
> with np.errstate(invalid='ignore'):
I see --- so abs([nan]) should emit a warning, but in the test we
should suppress it.
I'll work on that.
The only thing that I don't understand is why it only happens on some
platforms and doesn't on some other platforms (apparently). But it's
clear how to fix it now.
Thanks for the information.
More information about the NumPy-Discussion