summaryrefslogtreecommitdiff
path: root/numpy/lib/shape_base.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2018-07-29 23:18:31 -0700
committerEric Wieser <wieser.eric@gmail.com>2018-07-29 23:18:31 -0700
commit766d82f85ac04ffd9ba32e0266bc270acfe7ed60 (patch)
tree3f2600b8dff13f264bf28eee6556e5ff13f264c2 /numpy/lib/shape_base.py
parent083aedba2f49e1b490d3e122f5927f0718cf202c (diff)
downloadnumpy-766d82f85ac04ffd9ba32e0266bc270acfe7ed60.tar.gz
ENH: Make expand_dims work on subclasses
This allows np.ma.expand_dims to be removed
Diffstat (limited to 'numpy/lib/shape_base.py')
-rw-r--r--numpy/lib/shape_base.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
index 65104115a..d31d8a939 100644
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -536,7 +536,11 @@ def expand_dims(a, axis):
True
"""
- a = asarray(a)
+ if isinstance(a, matrix):
+ a = asarray(a)
+ else:
+ a = asanyarray(a)
+
shape = a.shape
if axis > a.ndim or axis < -a.ndim - 1:
# 2017-05-17, 1.13.0