[NumPy-Tickets] [NumPy] #1955: Assignment into sub-array fields functions wrong

NumPy Trac numpy-tickets@scipy....
Thu Sep 29 03:51:12 CDT 2011


#1955: Assignment into sub-array fields functions wrong
------------------------+---------------------------------------------------
 Reporter:  pv          |       Owner:  somebody   
     Type:  defect      |      Status:  new        
 Priority:  high        |   Milestone:  Unscheduled
Component:  numpy.core  |     Version:  1.6.0      
 Keywords:              |  
------------------------+---------------------------------------------------
 Consider assignment of an array to a sub-array field:
 {{{
 >>> import numpy as np
 >>> np.__version__
 '2.0.0.dev-fac8674'
 >>> dt = np.dtype('a3,(2,2)u2')
 >>> x = np.zeros(5, dtype=dt)
 >>> x[1]['f1'] = np.array([[1,1],[1,1]])
 >>> x[1]['f1']
 array([[1, 0],
        [0, 0]], dtype=uint16)
 }}}
 This is clearly wrong behavior.
 The problem has probably to do with assigning an array into an
 array scalar field.

 This works, however:
 {{{
 >>> x['f1'][1] = np.array([[2,2],[2,2]])
 >>> x[1]['f1']
 array([[2, 2],
        [2, 2]], dtype=uint16)
 }}}

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


More information about the NumPy-Tickets mailing list