[NumPy-Tickets] [NumPy] #2007: Correct handling of empty arrays

NumPy Trac numpy-tickets@scipy....
Wed Dec 28 08:21:04 CST 2011


#2007: Correct handling of empty arrays
--------------------------+-------------------------------------------------
 Reporter:  rgommers      |       Owner:  somebody   
     Type:  defect        |      Status:  new        
 Priority:  normal        |   Milestone:  Unscheduled
Component:  numpy.core    |     Version:  devel      
 Keywords:  empty arrays  |  
--------------------------+-------------------------------------------------
 This is a single ticket to describe issues related to empty arrays.
 Triggered by #1994 and discussion on ML starting on 25 Dec 2011 titled
 "Indexing empty dimensions with empty arrays".

 Empty arrays are not handled well in NumPy.  Operations like indexing
 should have well-defined behavior for empty arrays, and all functions
 should do something sensible.  A summary of how all this is supposed to
 work should be added to the User Guide.

 Issue: indexing with empty index array doesn't work on empty arrays with
 shape other than (0,):
 {{{
 >>> x = np.ones((5,0))
 >>> x[idx]  #works
 array([], shape=(0, 0), dtype=float64)
 >>> x[:, idx]  #doesn't work
 Traceback (most recent call last):
   File "<ipython-input-27-7038691cb565>", line 1, in <module>
     x[:, idx]  #doesn't work
 IndexError: invalid index
 }}}

 Issue: calculating a determinant of an empty array results in a segfault:
 {{{
 np.linalg.det(np.zeros((0,0)))
 Parameter 4 to routine DGETRF was incorrect
 <segfault>
 }}}

 All functions should do something sensible for all empty input.  Example:
 {{{
 >>> np.meshgrid([], [])   # ok
 (array([], shape=(0, 0), dtype=float64),
  array([], shape=(0, 0), dtype=float64))
 >>> np.meshgrid([], np.ones((3,0)))   # not ok
 ...
 ValueError
 }}}

 Patches to improve handling of empty array are very welcome.  New specific
 issues can be added to this ticket.

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


More information about the NumPy-Tickets mailing list