diff options
author | pierregm <pierregm@localhost> | 2010-09-13 15:43:27 +0000 |
---|---|---|
committer | pierregm <pierregm@localhost> | 2010-09-13 15:43:27 +0000 |
commit | 96afea0b32c77fa60112a1a78d66af77912e2523 (patch) | |
tree | e8dadd935c387ee5d07b200ae9adc7be4de50336 /numpy/ma/tests | |
parent | 7213c5d804412b1ab6f23c6419ba836865af517a (diff) | |
download | numpy-96afea0b32c77fa60112a1a78d66af77912e2523.tar.gz |
* ma.core._print_templates: switched the keys 'short' and 'long' to 'short_std' and 'long_std' respectively (bug #1586)
* Fixed incorrect broadcasting in ma.power (bug #1606)
Diffstat (limited to 'numpy/ma/tests')
-rw-r--r-- | numpy/ma/tests/test_core.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 908d7adc6..f907a3447 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -2975,6 +2975,39 @@ class TestMaskedArrayFunctions(TestCase): assert_almost_equal(x, y) assert_almost_equal(x._data, y._data) + def test_power_w_broadcasting(self): + "Test power w/ broadcasting" + a2 = np.array([[1., 2., 3.], [4., 5., 6.]]) + a2m = array(a2, mask=[[1, 0, 0], [0, 0, 1]]) + b1 = np.array([2, 4, 3]) + b1m = array(b1, mask=[0, 1, 0]) + b2 = np.array([b1, b1]) + b2m = array(b2, mask=[[0, 1, 0], [0, 1, 0]]) + # + ctrl = array([[1 ** 2, 2 ** 4, 3 ** 3], [4 ** 2, 5 ** 4, 6 ** 3]], + mask=[[1, 1, 0], [0, 1, 1]]) + # No broadcasting, base & exp w/ mask + test = a2m ** b2m + assert_equal(test, ctrl) + assert_equal(test.mask, ctrl.mask) + # No broadcasting, base w/ mask, exp w/o mask + test = a2m ** b2 + assert_equal(test, ctrl) + assert_equal(test.mask, a2m.mask) + # No broadcasting, base w/o mask, exp w/ mask + test = a2 ** b2m + assert_equal(test, ctrl) + assert_equal(test.mask, b2m.mask) + # + ctrl = array([[2 ** 2, 4 ** 4, 3 ** 3], [2 ** 2, 4 ** 4, 3 ** 3]], + mask=[[0, 1, 0], [0, 1, 0]]) + test = b1 ** b2m + assert_equal(test, ctrl) + assert_equal(test.mask, ctrl.mask) + test = b2m ** b1 + assert_equal(test, ctrl) + assert_equal(test.mask, ctrl.mask) + def test_where(self): "Test the where function" |