[NumPy-Tickets] [NumPy] #2254: Creating array from list of lists with differing lengths should raise exception

NumPy Trac numpy-tickets@scipy....
Wed Nov 28 04:22:39 CST 2012


#2254: Creating array from list of lists with differing lengths should raise
exception
----------------------------+-----------------------------------------------
 Reporter:  pdietrich       |       Owner:  somebody   
     Type:  defect          |      Status:  new        
 Priority:  normal          |   Milestone:  Unscheduled
Component:  numpy.core      |     Version:  1.6.1      
 Keywords:  array creation  |  
----------------------------+-----------------------------------------------
 When creating a multidimensional array from a list of lists, e.g.

 {{{
 In [43]: np.array([[23,2],[2,3]])
 Out[43]:
 array([[23,  2],
        [ 2,  3]])
 }}}



 where the inner lists do not have the same length, e.g.

 {{{
 In [44]: np.array([[23,2],[2]])
 Out[44]: array([[23, 2], [2]], dtype=object)
 }}}

 should raise an exception!

 The current behaviour of creating an array containing lists can lead to
 bugs which are hard to track down because they can cause errors in
 completely different parts of the program. E.g.

 {{{
 In [46]: np.array([[23,2],[2,3]]).flatten()
 Out[46]: array([23,  2,  2,  3])
 }}}

 but

 {{{
 In [47]: np.array([[23,2],[2]]).flatten()
 Out[47]: array([[23, 2], [2]], dtype=object)
 }}}

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


More information about the NumPy-Tickets mailing list