summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/ma/core.py3
-rw-r--r--numpy/ma/tests/test_core.py12
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):