[NumPy-Tickets] [NumPy] #1684: numpy.allclose does not deal well with the minimal value of int* dtypes

NumPy Trac numpy-tickets@scipy....
Mon Nov 22 13:57:43 CST 2010


#1684: numpy.allclose does not deal well with the minimal value of int* dtypes
------------------------+---------------------------------------------------
 Reporter:  lamblin     |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  normal      |   Milestone:  2.0.0   
Component:  numpy.core  |     Version:  1.5.0   
 Keywords:              |  
------------------------+---------------------------------------------------

Comment(by lamblin):

 A workaround is to upcast the second argument to float64 if its absolute
 value has a negative element:
 {{{
 def _allclose(a, b, rtol=1e-5, atol=1e-8):
     if str(b.dtype).startswith('int') and (numpy.absolute(b) < 0).any():
         b = numpy.asarray(b, dtype='float64')

     return numpy.allclose(a, b, rtol=rtol, atol=atol)
 }}}

 I don't know if this should be fixed at the level of allclose, or of
 absolute.

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


More information about the NumPy-Tickets mailing list