[Numpy-svn] r6094 - in trunk/numpy/ma: . tests

numpy-svn@scip... numpy-svn@scip...
Sat Nov 22 18:04:31 CST 2008


Author: pierregm
Date: 2008-11-22 18:04:29 -0600 (Sat, 22 Nov 2008)
New Revision: 6094

Modified:
   trunk/numpy/ma/core.py
   trunk/numpy/ma/tests/test_core.py
Log:
Added mod to the ufuncs

Modified: trunk/numpy/ma/core.py
===================================================================
--- trunk/numpy/ma/core.py	2008-11-22 08:01:26 UTC (rev 6093)
+++ trunk/numpy/ma/core.py	2008-11-23 00:04:29 UTC (rev 6094)
@@ -46,7 +46,7 @@
            '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 @@
 remainder = _DomainedBinaryOperation(umath.remainder,
                                       _DomainSafeDivide(), 0, 1)
 fmod = _DomainedBinaryOperation(umath.fmod, _DomainSafeDivide(), 0, 1)
+mod = _DomainedBinaryOperation(umath.mod, _DomainSafeDivide(), 0, 1)
 
 
 #####--------------------------------------------------------------------------

Modified: trunk/numpy/ma/tests/test_core.py
===================================================================
--- trunk/numpy/ma/tests/test_core.py	2008-11-22 08:01:26 UTC (rev 6093)
+++ trunk/numpy/ma/tests/test_core.py	2008-11-23 00:04:29 UTC (rev 6094)
@@ -752,9 +752,19 @@
             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):
         "Test of take, transpose, inner, outer products"
         x = arange(24)



More information about the Numpy-svn mailing list