diff options
author | Ralf Gommers <ralf.gommers@gmail.com> | 2018-07-31 11:15:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-31 11:15:30 -0700 |
commit | b0832bd6d28c4ec109184c37673984cdc677156c (patch) | |
tree | 880e44d48ddbf4909d50acb718d2bccbe05a19be /numpy/matrixlib/tests/test_defmatrix.py | |
parent | a591b4abca82df4361a34d7e4388335958c42808 (diff) | |
parent | 455b5c567f75486b121c33f82bcb8f8da9683b5a (diff) | |
download | numpy-b0832bd6d28c4ec109184c37673984cdc677156c.tar.gz |
Merge pull request #11638 from eric-wieser/remove-ma.expand_dims
ENH: Make expand_dims work on subclasses
Diffstat (limited to 'numpy/matrixlib/tests/test_defmatrix.py')
-rw-r--r-- | numpy/matrixlib/tests/test_defmatrix.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/numpy/matrixlib/tests/test_defmatrix.py b/numpy/matrixlib/tests/test_defmatrix.py index e74e83cdb..272cd8d52 100644 --- a/numpy/matrixlib/tests/test_defmatrix.py +++ b/numpy/matrixlib/tests/test_defmatrix.py @@ -466,3 +466,11 @@ class TestShape(object): def test_matrix_memory_sharing(self): assert_(np.may_share_memory(self.m, self.m.ravel())) assert_(not np.may_share_memory(self.m, self.m.flatten())) + + def test_expand_dims_matrix(self): + # matrices are always 2d - so expand_dims only makes sense when the + # type is changed away from matrix. + a = np.arange(10).reshape((2, 5)).view(np.matrix) + expanded = np.expand_dims(a, axis=1) + assert_equal(expanded.ndim, 3) + assert_(not isinstance(expanded, np.matrix)) |