diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2018-07-29 23:18:31 -0700 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2018-07-29 23:18:31 -0700 |
commit | 766d82f85ac04ffd9ba32e0266bc270acfe7ed60 (patch) | |
tree | 3f2600b8dff13f264bf28eee6556e5ff13f264c2 /numpy/lib/shape_base.py | |
parent | 083aedba2f49e1b490d3e122f5927f0718cf202c (diff) | |
download | numpy-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.py | 6 |
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 |