From fd19f049670b8dd609f65e34d0267b6491635d1a Mon Sep 17 00:00:00 2001 From: Mark Wiebe Date: Tue, 26 Oct 2010 15:59:37 -0700 Subject: BUG: core: Enabled keyword argument for 'order' parameter where it was missing, and tweaked some docs (#1581) --- numpy/core/fromnumeric.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'numpy/core/fromnumeric.py') diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 39bb8b348..e97e50c87 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -117,9 +117,10 @@ def reshape(a, newshape, order='C'): an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions. - order : {'C', 'F'}, optional + order : {'C', 'F', 'A'}, optional Determines whether the array data should be viewed as in C - (row-major) order or FORTRAN (column-major) order. + (row-major) order, FORTRAN (column-major) order, or the C/FORTRAN + order should be preserved. Returns ------- @@ -1052,9 +1053,10 @@ def ravel(a, order='C'): a : array_like Input array. The elements in `a` are read in the order specified by `order`, and packed as a 1-D array. - order : {'C','F'}, optional - The elements of `a` are read in this order. It can be either - 'C' for row-major order, or `F` for column-major order. + order : {'C','F', 'A'}, optional + The elements of `a` are read in this order. It can be + 'C' for row-major order, `F` for column-major order, or + 'A' to preserve the order of `a` when possible. By default, row-major order is used. Returns @@ -1078,21 +1080,24 @@ def ravel(a, order='C'): Examples -------- - If an array is in C-order (default), then `ravel` is equivalent - to ``reshape(-1)``: + It is equivalent to ``reshape(-1, order=order)``. >>> x = np.array([[1, 2, 3], [4, 5, 6]]) - >>> print x.reshape(-1) - [1 2 3 4 5 6] - >>> print np.ravel(x) - [1 2 3 4 5 6] + [1 2 3 4 5 6] - When flattening using Fortran-order, however, we see + >>> print x.reshape(-1) + [1 2 3 4 5 6] >>> print np.ravel(x, order='F') [1 4 2 5 3 6] + When `order` is 'A', it will preserve the array's 'C' or 'F' ordering: + + >>> print np.ravel(x.T) + [1 4 2 5 3 6] + >>> print np.ravel(x.T, order='A') + [1 2 3 4 5 6] """ return asarray(a).ravel(order) -- cgit v1.2.1