summaryrefslogtreecommitdiff
path: root/numpy/core/fromnumeric.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r--numpy/core/fromnumeric.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index 43584349f..4dfeb35ca 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -657,8 +657,9 @@ def partition(a, kth, axis=-1, kind='introselect', order=None):
"""
if axis is None:
+ # flatten returns (1, N) for np.matrix, so always use the last axis
a = asanyarray(a).flatten()
- axis = 0
+ axis = -1
else:
a = asanyarray(a).copy(order="K")
a.partition(kth, axis=axis, kind=kind, order=order)
@@ -840,8 +841,9 @@ def sort(a, axis=-1, kind='quicksort', order=None):
"""
if axis is None:
+ # flatten returns (1, N) for np.matrix, so always use the last axis
a = asanyarray(a).flatten()
- axis = 0
+ axis = -1
else:
a = asanyarray(a).copy(order="K")
a.sort(axis=axis, kind=kind, order=order)