diff options
author | Garrett-R <garrettreynolds5@gmail.com> | 2014-12-16 22:50:26 -0800 |
---|---|---|
committer | Garrett-R <garrettreynolds5@gmail.com> | 2015-01-02 10:52:05 +0530 |
commit | 78f69df28acd80654705a43bcf1e977b9c423b53 (patch) | |
tree | c591ae02c93cafb3caf861b997a665c0c3011122 /numpy/core/fromnumeric.py | |
parent | fb898ce678c8d45364d1ee7b1a6d0308562a8ad9 (diff) | |
download | numpy-78f69df28acd80654705a43bcf1e977b9c423b53.tar.gz |
BUG: Fixes #5376: np.ravel to return same array type
In PR #5358, np.diagonal was modified to return whatever array type it took in.
Also, np.cumsum and np.clip return the same array type. So, np.ravel's behavior is surprising.
Two tests which were expecting np.ravel to return an array have been changed.
Also, the optional `order` parameter was added to MaskedArray.ravel to make it compatible
(matrix.ravel already had this parameter).
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r-- | numpy/core/fromnumeric.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 321deb014..2dc270a28 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1340,6 +1340,10 @@ def ravel(a, order='C'): A 1-D array, containing the elements of the input, is returned. A copy is made only if needed. + As of NumPy 1.10, the returned array will have the same type as the input + array. (for example, a masked array will be returned for a masked array + input) + Parameters ---------- a : array_like @@ -1361,8 +1365,9 @@ def ravel(a, order='C'): Returns ------- - 1d_array : ndarray - Output of the same dtype as `a`, and of shape ``(a.size,)``. + y : array_like + Array of the same type as `a`, and of shape ``(a.size,)`` + or ``(1, a.size)`` for matrices. See Also -------- @@ -1420,7 +1425,7 @@ def ravel(a, order='C'): array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) """ - return asarray(a).ravel(order) + return asanyarray(a).ravel(order) def nonzero(a): |