[NumPy-Tickets] [NumPy] #2140: Error in deleting an empty row with numpy.delete

NumPy Trac numpy-tickets@scipy....
Tue May 22 05:31:49 CDT 2012


#2140: Error in deleting an empty row with numpy.delete
--------------------+-------------------------------------------------------
 Reporter:  jansb   |       Owner:  somebody   
     Type:  defect  |      Status:  new        
 Priority:  normal  |   Milestone:  Unscheduled
Component:  Other   |     Version:  1.6.1      
 Keywords:  delete  |  
--------------------+-------------------------------------------------------
 Hello,

 I get an error when I try to delete nothing from an array with a shape of
 one axis equal zero.

 What works:

 {{{
 In [1]: z=np.zeros((0,))

 In [2]: z, z.shape
 Out[2]: (array([], dtype=float64), (0,))

 In [3]: numpy.delete(z,[],0)
 Out[3]: array([], dtype=float64)
 }}}

 What gives an index error:

 {{{
 In [4]: z=np.zeros((0,2))

 In [5]: z, z.shape
 Out[5]: (array([], shape=(0, 2), dtype=float64), (0, 2))

 In [6]: numpy.delete(z,[],0)
 ---------------------------------------------------------------------------
 IndexError                                Traceback (most recent call
 last)
 /home/jansb/.local/share/Trash/files/estimbuilder 3/tests/<ipython-
 input-6-f9a27bc2cbeb> in <module>()
 ----> 1 numpy.delete(z,[],0)

 /usr/lib/python2.7/dist-packages/numpy/lib/function_base.pyc in
 delete(arr, obj, axis)
    3383         obj = setdiff1d(all, obj)
    3384         slobj[axis] = obj
 -> 3385         new = arr[slobj]
    3386     if wrap:
    3387         return wrap(new)

 IndexError: invalid index
 }}}

 What works:

 {{{
 In [8]: z=np.zeros((0,2))

 In [9]: z, z.shape
 Out[9]: (array([], shape=(0, 2), dtype=float64), (0, 2))

 In [10]: numpy.delete(z,[],1)
 Out[10]: array([], shape=(0, 2), dtype=float64)
 }}}

 Is this a bug or wanted behaviour?

 Best regards,
 jansb

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


More information about the NumPy-Tickets mailing list