[NumPy-Tickets] [NumPy] #1516: Numpy float cast to int when multiplying a python list

NumPy Trac numpy-tickets@scipy....
Sun Jun 20 16:11:02 CDT 2010


#1516: Numpy float cast to int when multiplying a python list
--------------------+-------------------------------------------------------
 Reporter:  tsyu    |       Owner:  somebody
     Type:  defect  |      Status:  new     
 Priority:  normal  |   Milestone:  2.0.0   
Component:  Other   |     Version:          
 Keywords:          |  
--------------------+-------------------------------------------------------
 When multiplying a numpy float and a python list, the float is cast as an
 int and then does the usual python thing (creates duplicates of the
 original sequence).

 For example,
 {{{
 >>> np.float64(2.3) * [1, 2]
 [1, 2, 1, 2]
 }}}

 Instead, the multiplication should either work like an array scalar:
 {{{
 >>> np.array(2.3) * [1, 2]
 array([ 2.3,  4.6])
 }}}

 or throw an exception like a python float:
 {{{
 >>> 2.3 * [1, 2]
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 TypeError: can't multiply sequence by non-int of type 'float'
 }}}

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


More information about the NumPy-Tickets mailing list