[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:15:47 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:              |  
------------------------+---------------------------------------------------
 If I create an array containing the minimal value of an int dtype, for
 instance an 'int8' array containing -128, numpy.allclose fails to detect
 it is "close" to itself, although it is equal.
 {{{
 >>> a = numpy.asarray(-128, dtype='int8')
 >>> numpy.all(a == a)
 True
 >>> numpy.allclose(a, a)
 False
 }}}

 I would expect:
 {{{
 >>> numpy.allclose(a, a)
 True
 }}}

 This is due to the fact that the tolerance uses numpy.absolute, and in
 that case, it is negative:
 {{{
 >>> numpy.absolute(a)
 array([-128], dtype=int8)
 }}}

 I reproduced the same with int16 and -2**15, int32 and -2**31, and int64
 and -2**63.

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


More information about the NumPy-Tickets mailing list