[NumPy-Tickets] [NumPy] #1905: numpy/core/numeric/allclose() fails to test for NaN inputs

NumPy Trac numpy-tickets@scipy....
Fri Jul 15 14:41:20 CDT 2011


#1905: numpy/core/numeric/allclose() fails to test for NaN inputs
------------------------+---------------------------------------------------
 Reporter:  robertpyle  |       Owner:  somebody   
     Type:  defect      |      Status:  new        
 Priority:  normal      |   Milestone:  Unscheduled
Component:  Other       |     Version:  1.6.0      
 Keywords:              |  
------------------------+---------------------------------------------------

Old description:

> Despite a comment that says NaNs in either input cause it to return
> False, routine allclose() in core/numeric.py fails to test its inputs for
> NaN.  This causes a warning to be issued by numpy.test(), at least on
> MacOSX 10.6.8  with python.org python2.7.1, numpy 1.6.1.rc3.
>
> A 2-line addition fixes this.  Here's the diff:
>
> 1915a1916,1917
> >     if any(isnan(x)) or any(isnan(y)):
> >         return False

New description:

 Despite a comment that says NaNs in either input cause it to return False,
 routine allclose() in core/numeric.py fails to test its inputs for NaN.
 This causes a warning to be issued by numpy.test(), at least on MacOSX
 10.6.8  with python.org python2.7.1, numpy 1.6.1.rc3.

 A 2-line addition fixes this.  Here's the diff:
 {{{
 1915a1916,1917
 >     if any(isnan(x)) or any(isnan(y)):
 >         return False
 }}}

--

Comment(by rgommers):

 This warning only appears with (32-bit) Python 2.7, not 2.6 on OS X:
 {{{
 $ python2.7
 >>> from numpy import *
 >>> absolute(nan)
 __main__:1: RuntimeWarning: invalid value encountered in absolute
 nan

 $ python2.6
 >>> from numpy import *
 >>> absolute(nan)
 nan
 }}}

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1905#comment:1>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list