[NumPy-Tickets] [NumPy] #1798: Type promotion rules regression

NumPy Trac numpy-tickets@scipy....
Mon Apr 11 18:07:21 CDT 2011


#1798: Type promotion rules regression
------------------------+---------------------------------------------------
 Reporter:  mwiebe      |       Owner:  mwiebe
     Type:  defect      |      Status:  new   
 Priority:  highest     |   Milestone:  1.6.0 
Component:  numpy.core  |     Version:  devel 
 Keywords:              |  
------------------------+---------------------------------------------------

Comment(by mwiebe):

 The old behavior depended on the scalar value in the same way, except it
 only used the scalar's value to detect int -> uint. This is so that
 [float64 scalar]*[float32 array] produces a [float32 array] instead of a
 [float64 array]. Without this rule, using float32 arrays is almost
 impossible since they will be promoted to float64 in many circumstances. I
 generalized it to also use the value to avoid obvious overflows.

 1.5.x and earlier:
 {{{
 >>> 100000*np.ones(2,dtype=np.int8)
 array([-31072, -31072], dtype=int16)
 >>> 1e60*np.ones(2,dtype=np.float32)
 array([ Inf,  Inf], dtype=float32)
 }}}

 1.6 and later:
 {{{
 >>> 100000*np.ones(2,dtype=np.int8)
 array([100000, 100000], dtype=int32)
 >>> 1e60*np.ones(2,dtype=np.float32)
 array([  1.00000000e+60,   1.00000000e+60])
 }}}

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


More information about the NumPy-Tickets mailing list