From ea927d961dfc32b6963aed3b3a10bc51c12543df Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 3 Jan 2015 17:55:43 -0700 Subject: BUG: Make ravel function return 1-D arrays for matrix argument. This is a backward compatibility hack to avoid breaking scipy.sparse after fixing ravel to respect subtypes. Subtypes are still respected except in the case of matrices and subclasses of matrices. --- 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 da61fc187..2a527a4a4 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1376,8 +1376,10 @@ def ravel(a, order='C'): Returns ------- y : array_like - Array of the same type as `a`, and of shape ``(a.size,)`` - or ``(1, a.size)`` for matrices. + If `a` is a matrix, y is a 1-D ndarray, otherwise y is an array of + the same subtype as `a`. The shape of the returned array is + ``(a.size,)``. Matrices are special cased for backward + compatibility. See Also -------- @@ -1435,7 +1437,10 @@ def ravel(a, order='C'): array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) """ - return asanyarray(a).ravel(order) + if isinstance(a, np.matrix): + return asarray(a).ravel(order) + else: + return asanyarray(a).ravel(order) def nonzero(a): -- cgit v1.2.1