diff options
-rw-r--r-- | numpy/ma/tests/test_core.py | 4 | ||||
-rw-r--r-- | numpy/ma/tests/test_extras.py | 54 |
2 files changed, 37 insertions, 21 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 70c1ee12c..61fd77bda 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -3192,7 +3192,7 @@ class TestMaskedArrayMathMethods(TestCase): assert_almost_equal(r.filled(0), fX.dot(fX)) assert_(r.mask[1,3]) r1 = empty_like(r) - mX.dot(mX, r1) + mX.dot(mX, out=r1) assert_almost_equal(r, r1) mYY = mXX.swapaxes(-1, -2) @@ -3200,7 +3200,7 @@ class TestMaskedArrayMathMethods(TestCase): r = mXX.dot(mYY) assert_almost_equal(r.filled(0), fXX.dot(fYY)) r1 = empty_like(r) - mXX.dot(mYY, r1) + mXX.dot(mYY, out=r1) assert_almost_equal(r, r1) def test_dot_shape_mismatch(self): diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py index c41c629fc..6138d0573 100644 --- a/numpy/ma/tests/test_extras.py +++ b/numpy/ma/tests/test_extras.py @@ -538,26 +538,26 @@ class TestCompressFunctions(TestCase): m = [1, 0, 0, 0, 0, 0] a = masked_array(n, mask=m).reshape(2, 3) b = masked_array(n, mask=m).reshape(3, 2) - c = dot(a, b, True) + c = dot(a, b, strict=True) assert_equal(c.mask, [[1, 1], [1, 0]]) - c = dot(b, a, True) + c = dot(b, a, strict=True) assert_equal(c.mask, [[1, 1, 1], [1, 0, 0], [1, 0, 0]]) - c = dot(a, b, False) + c = dot(a, b, strict=False) assert_equal(c, np.dot(a.filled(0), b.filled(0))) - c = dot(b, a, False) + c = dot(b, a, strict=False) assert_equal(c, np.dot(b.filled(0), a.filled(0))) # m = [0, 0, 0, 0, 0, 1] a = masked_array(n, mask=m).reshape(2, 3) b = masked_array(n, mask=m).reshape(3, 2) - c = dot(a, b, True) + c = dot(a, b, strict=True) assert_equal(c.mask, [[0, 1], [1, 1]]) - c = dot(b, a, True) + c = dot(b, a, strict=True) assert_equal(c.mask, [[0, 0, 1], [0, 0, 1], [1, 1, 1]]) - c = dot(a, b, False) + c = dot(a, b, strict=False) assert_equal(c, np.dot(a.filled(0), b.filled(0))) assert_equal(c, dot(a, b)) - c = dot(b, a, False) + c = dot(b, a, strict=False) assert_equal(c, np.dot(b.filled(0), a.filled(0))) # m = [0, 0, 0, 0, 0, 0] @@ -570,37 +570,53 @@ class TestCompressFunctions(TestCase): # a = masked_array(n, mask=[1, 0, 0, 0, 0, 0]).reshape(2, 3) b = masked_array(n, mask=[0, 0, 0, 0, 0, 0]).reshape(3, 2) - c = dot(a, b, True) + c = dot(a, b, strict=True) assert_equal(c.mask, [[1, 1], [0, 0]]) - c = dot(a, b, False) + c = dot(a, b, strict=False) assert_equal(c, np.dot(a.filled(0), b.filled(0))) - c = dot(b, a, True) + c = dot(b, a, strict=True) assert_equal(c.mask, [[1, 0, 0], [1, 0, 0], [1, 0, 0]]) - c = dot(b, a, False) + c = dot(b, a, strict=False) assert_equal(c, np.dot(b.filled(0), a.filled(0))) # a = masked_array(n, mask=[0, 0, 0, 0, 0, 1]).reshape(2, 3) b = masked_array(n, mask=[0, 0, 0, 0, 0, 0]).reshape(3, 2) - c = dot(a, b, True) + c = dot(a, b, strict=True) assert_equal(c.mask, [[0, 0], [1, 1]]) c = dot(a, b) assert_equal(c, np.dot(a.filled(0), b.filled(0))) - c = dot(b, a, True) + c = dot(b, a, strict=True) assert_equal(c.mask, [[0, 0, 1], [0, 0, 1], [0, 0, 1]]) - c = dot(b, a, False) + c = dot(b, a, strict=False) assert_equal(c, np.dot(b.filled(0), a.filled(0))) # a = masked_array(n, mask=[0, 0, 0, 0, 0, 1]).reshape(2, 3) b = masked_array(n, mask=[0, 0, 1, 0, 0, 0]).reshape(3, 2) - c = dot(a, b, True) + c = dot(a, b, strict=True) assert_equal(c.mask, [[1, 0], [1, 1]]) - c = dot(a, b, False) + c = dot(a, b, strict=False) assert_equal(c, np.dot(a.filled(0), b.filled(0))) - c = dot(b, a, True) + c = dot(b, a, strict=True) assert_equal(c.mask, [[0, 0, 1], [1, 1, 1], [0, 0, 1]]) - c = dot(b, a, False) + c = dot(b, a, strict=False) assert_equal(c, np.dot(b.filled(0), a.filled(0))) + def test_dot_returns_maskedarray(self): + # See gh-6611 + a = np.eye(3) + b = array(a) + assert_(type(dot(a, a)) is MaskedArray) + assert_(type(dot(a, b)) is MaskedArray) + assert_(type(dot(b, a)) is MaskedArray) + assert_(type(dot(b, b)) is MaskedArray) + + def test_dot_out(self): + a = array(np.eye(3)) + out = array(np.zeros((3, 3))) + res = dot(a, a, out=out) + assert_(res is out) + assert_equal(a, res) + class TestApplyAlongAxis(TestCase): # Tests 2D functions |