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

numpy-svn@scip... numpy-svn@scip...
Tue Sep 9 13:25:18 CDT 2008


Author: pierregm
Date: 2008-09-09 13:25:15 -0500 (Tue, 09 Sep 2008)
New Revision: 5800

Modified:
   trunk/numpy/ma/core.py
   trunk/numpy/ma/tests/test_core.py
Log:
* make sure that minimum & maximum actually return a MaskedArray

Modified: trunk/numpy/ma/core.py
===================================================================
--- trunk/numpy/ma/core.py	2008-09-09 17:48:47 UTC (rev 5799)
+++ trunk/numpy/ma/core.py	2008-09-09 18:25:15 UTC (rev 5800)
@@ -3231,6 +3231,8 @@
             mb = getmaskarray(b)
             m = logical_or.outer(ma, mb)
         result = self.ufunc.outer(filled(a), filled(b))
+        if not isinstance(result, MaskedArray):
+            result = result.view(MaskedArray)
         result._mask = m
         return result
 

Modified: trunk/numpy/ma/tests/test_core.py
===================================================================
--- trunk/numpy/ma/tests/test_core.py	2008-09-09 17:48:47 UTC (rev 5799)
+++ trunk/numpy/ma/tests/test_core.py	2008-09-09 18:25:15 UTC (rev 5800)
@@ -656,6 +656,23 @@
         x[-1,-1] = masked
         assert_equal(maximum(x), 2)
 
+    def test_minimummaximum_func(self):
+        a = np.ones((2,2))
+        aminimum = minimum(a,a)
+        assert(isinstance(aminimum, MaskedArray))
+        assert_equal(aminimum, np.minimum(a,a))
+        #
+        aminimum = minimum.outer(a,a)
+        assert(isinstance(aminimum, MaskedArray))
+        assert_equal(aminimum, np.minimum.outer(a,a))
+        #
+        amaximum = maximum(a,a)
+        assert(isinstance(amaximum, MaskedArray))
+        assert_equal(amaximum, np.maximum(a,a))
+        #
+        amaximum = maximum.outer(a,a)
+        assert(isinstance(amaximum, MaskedArray))
+        assert_equal(amaximum, np.maximum.outer(a,a))
 
     def test_minmax_funcs_with_output(self):
         "Tests the min/max functions with explicit outputs"



More information about the Numpy-svn mailing list