From 78f69df28acd80654705a43bcf1e977b9c423b53 Mon Sep 17 00:00:00 2001 From: Garrett-R Date: Tue, 16 Dec 2014 22:50:26 -0800 Subject: 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). --- numpy/core/fromnumeric.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'numpy/core/fromnumeric.py') 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): -- cgit v1.2.1