[NumPy-Tickets] [NumPy] #1902: numpy.ma.compress fails because of the argument order

NumPy Trac numpy-tickets@scipy....
Mon Jul 11 14:58:27 CDT 2011

#1902: numpy.ma.compress fails because of the argument order
 Reporter:  efiring   |       Owner:  pierregm   
     Type:  defect    |      Status:  new        
 Priority:  normal    |   Milestone:  Unscheduled
Component:  numpy.ma  |     Version:  devel      
 Keywords:            |  
 The _frommethod class used to make ma.compress assumes the first argument
 is the object on which the function is acting, but the compress signature
 is compress(cond, arr). Example of the resulting failure:

 In [14]: arr = np.arange(8)

 In [15]: arr.shape = 4,2

 In [16]: cond = np.array([True, False, True, True])

 In [17]: np.ma.compress(cond, arr, axis=0)
 ValueError                                Traceback (most recent call
 /home/efiring/<ipython-input-17-50a13b754f15> in <module>()
 ----> 1 np.ma.compress(cond, arr, axis=0)

 /usr/local/lib/python2.7/dist-packages/numpy/ma/core.pyc in __call__(self,
 a, *args, **params)
    5931         method = getattr(a, method_name, None)
    5932         if method is not None:
 -> 5933             return method(*args, **params)
    5934         # Still here ? Then a is not a MaskedArray

    5935         method = getattr(MaskedArray, method_name, None)

 ValueError: condition must be 1-d array


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

More information about the NumPy-Tickets mailing list