[Numpy-discussion] adding 'order=' keyword arg to ravel and others

Pauli Virtanen pav@iki...
Wed Oct 27 04:36:22 CDT 2010


Tue, 26 Oct 2010 22:05:52 -0700, Mark Wiebe wrote:
> Because writing "arr.ravel('F')" doesn't seem as descriptive as
> "arr.ravel(order='F')", I wrote this simple patch.  I added mention of
> the order='A' parameter to a few places it is relevant as well.  Here's
> the branch on github:
> 
> http://github.com/m-paradox/numpy/compare/master...ravel_keyword_arg
> 
> Could someone review it for me?

There is the following problem:

>>> import numpy as np
>>> x=np.arange(9).reshape(3,3)
>>> x.T.flatten()
array([0, 3, 6, 1, 4, 7, 2, 5, 8])
>>> x.T.flatten(order=None)
array([0, 1, 2, 3, 4, 5, 6, 7, 8])

PyArray_OrderConverter interprets `None` as "A". However, this problem is 
already there with `reshape`, so this patch looks good to me -- fixing 
OrderConverter is a separate job.

-- 
Pauli Virtanen



More information about the NumPy-Discussion mailing list