diff options
author | pierregm <pierregm@localhost> | 2008-11-23 00:04:29 +0000 |
---|---|---|
committer | pierregm <pierregm@localhost> | 2008-11-23 00:04:29 +0000 |
commit | 638bacdd9212dd2258a886e0124cca56bf2b905d (patch) | |
tree | a747e9a6314ecf443788abadfa9c435c86a5f664 | |
parent | 0cb27e398522fdbfed7ed974538ad6d24347c10a (diff) | |
download | numpy-638bacdd9212dd2258a886e0124cca56bf2b905d.tar.gz |
Added mod to the ufuncs
-rw-r--r-- | numpy/ma/core.py | 3 | ||||
-rw-r--r-- | numpy/ma/tests/test_core.py | 12 |
2 files changed, 13 insertions, 2 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index a341af5e0..7bf71ca13 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -46,7 +46,7 @@ __all__ = ['MAError', 'MaskType', 'MaskedArray', 'masked_object','masked_outside', 'masked_print_option', 'masked_singleton','masked_values', 'masked_where', 'max', 'maximum', 'maximum_fill_value', 'mean', 'min', 'minimum', 'minimum_fill_value', - 'multiply', + 'mod', 'multiply', 'negative', 'nomask', 'nonzero', 'not_equal', 'ones', 'outer', 'outerproduct', 'power', 'product', 'ptp', 'put', 'putmask', @@ -768,6 +768,7 @@ floor_divide = _DomainedBinaryOperation(umath.floor_divide, remainder = _DomainedBinaryOperation(umath.remainder, _DomainSafeDivide(), 0, 1) fmod = _DomainedBinaryOperation(umath.fmod, _DomainSafeDivide(), 0, 1) +mod = _DomainedBinaryOperation(umath.mod, _DomainSafeDivide(), 0, 1) #####-------------------------------------------------------------------------- diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index df601433c..b51a90712 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -752,7 +752,17 @@ class TestMaskedArrayArithmetic(TestCase): assert_equal(np.sum(x,1), sum(x,1)) assert_equal(np.product(x,1), product(x,1)) - + def test_mod(self): + "Tests mod" + (x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d + assert_equal(mod(x, y), mod(xm, ym)) + test = mod(ym, xm) + assert_equal(test, np.mod(ym, xm)) + assert_equal(test.mask, mask_or(xm.mask, ym.mask)) + test = mod(xm, ym) + assert_equal(test, np.mod(xm, ym)) + assert_equal(test.mask, mask_or(mask_or(xm.mask, ym.mask), (ym == 0))) + def test_TakeTransposeInnerOuter(self): |