[NumPy-Tickets] [NumPy] #1581: arr.copy(order={'C', 'F'}) raises TypeError

NumPy Trac numpy-tickets@scipy....
Fri Aug 13 08:47:27 CDT 2010


#1581: arr.copy(order={'C','F'}) raises TypeError
------------------------+---------------------------------------------------
 Reporter:  kwmsmith    |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  normal      |   Milestone:  2.0.0   
Component:  numpy.core  |     Version:          
 Keywords:              |  
------------------------+---------------------------------------------------
 I'd really like `arr.copy(order='F')` to work -- is it supposed to as
 its docstring says, or is it supposed to raise a `TypeError` as it does
 now?

 This is on numpy 1.4

 {{{
 >>> import numpy as np
 >>> a = np.arange(10).reshape(5,2)
 >>> a
 array([[0, 1],
       [2, 3],
       [4, 5],
       [6, 7],
       [8, 9]])
 >>> print a.copy.__doc__
 a.copy(order='C')

    Return a copy of the array.

    Parameters
    ----------
    order : {'C', 'F', 'A'}, optional
        By default, the result is stored in C-contiguous (row-major) order
 in
        memory.  If `order` is `F`, the result has 'Fortran' (column-major)
        order.  If order is 'A' ('Any'), then the result has the same order
        as the input.

    Examples
    --------
    >>> x = np.array([[1,2,3],[4,5,6]], order='F')

    >>> y = x.copy()

    >>> x.fill(0)

    >>> x
    array([[0, 0, 0],
           [0, 0, 0]])

    >>> y
    array([[1, 2, 3],
           [4, 5, 6]])

    >>> y.flags['C_CONTIGUOUS']
    True
 >>> a.copy(order='C')
 Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
 TypeError: copy() takes no keyword arguments
 >>> a.copy(order='F')
 Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
 TypeError: copy() takes no keyword arguments
 >>>
 }}}

 From Pauli Virtanen:

 The problem is probably that the function is using `PyArg_ParseTuple`
 instead of `PyArg_ParseTupleAndKeywords`.

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


More information about the NumPy-Tickets mailing list