summaryrefslogtreecommitdiff
path: root/numpy/core/fromnumeric.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2015-01-03 17:55:43 -0700
committerCharles Harris <charlesr.harris@gmail.com>2015-01-04 08:17:46 -0700
commitea927d961dfc32b6963aed3b3a10bc51c12543df (patch)
tree2381b2f1a9613b43a1614a38218f220a5ecd7c92 /numpy/core/fromnumeric.py
parentad2d26442a4cf39ca378040f56ee928e673ad42a (diff)
downloadnumpy-ea927d961dfc32b6963aed3b3a10bc51c12543df.tar.gz
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.
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r--numpy/core/fromnumeric.py11
1 files changed, 8 insertions, 3 deletions
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):