diff options
Diffstat (limited to 'numpy/matrixlib/tests/test_masked_matrix.py')
-rw-r--r-- | numpy/matrixlib/tests/test_masked_matrix.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/numpy/matrixlib/tests/test_masked_matrix.py b/numpy/matrixlib/tests/test_masked_matrix.py index 80d1cacca..0a0d985c4 100644 --- a/numpy/matrixlib/tests/test_masked_matrix.py +++ b/numpy/matrixlib/tests/test_masked_matrix.py @@ -3,10 +3,12 @@ from __future__ import division, absolute_import, print_function import pickle import numpy as np -from numpy.ma.testutils import assert_, assert_equal +from numpy.ma.testutils import (assert_, assert_equal, assert_raises, + assert_array_equal) from numpy.ma.core import (masked_array, masked_values, masked, allequal, MaskType, getmask, MaskedArray, nomask, log, add, hypot, divide) +from numpy.ma.extras import mr_ class MMatrix(MaskedArray, np.matrix,): @@ -209,3 +211,21 @@ class TestSubclassing(object): assert_(isinstance(divide(mx, mx), MMatrix)) assert_(isinstance(divide(mx, x), MMatrix)) assert_equal(divide(mx, mx), divide(xmx, xmx)) + +class TestConcatenator(object): + # Tests for mr_, the equivalent of r_ for masked arrays. + + def test_matrix_builder(self): + assert_raises(np.ma.MAError, lambda: mr_['1, 2; 3, 4']) + + def test_matrix(self): + # Test consistency with unmasked version. If we ever deprecate + # matrix, this test should either still pass, or both actual and + # expected should fail to be build. + actual = mr_['r', 1, 2, 3] + expected = np.ma.array(np.r_['r', 1, 2, 3]) + assert_array_equal(actual, expected) + + # outer type is masked array, inner type is matrix + assert_equal(type(actual), type(expected)) + assert_equal(type(actual.data), type(expected.data)) |