[Scipy-svn] r3412 - in trunk/scipy/sandbox/maskedarray: . tests

scipy-svn at scipy.org scipy-svn at scipy.org
Thu Oct 4 13:43:53 EDT 2007


Author: pierregm
Date: 2007-10-04 12:43:51 -0500 (Thu, 04 Oct 2007)
New Revision: 3412

Modified:
   trunk/scipy/sandbox/maskedarray/core.py
   trunk/scipy/sandbox/maskedarray/tests/test_subclassing.py
Log:
core: fixed any
test_subclassing : fixed _get_series

Modified: trunk/scipy/sandbox/maskedarray/core.py
===================================================================
--- trunk/scipy/sandbox/maskedarray/core.py	2007-10-04 17:41:49 UTC (rev 3411)
+++ trunk/scipy/sandbox/maskedarray/core.py	2007-10-04 17:43:51 UTC (rev 3412)
@@ -1503,7 +1503,7 @@
     def __idiv__(self, other):
         "Divides self by other in place."
         other_data = getdata(other)
-        dom_mask = domain_safe_divide().__call__(self._data, other_data)
+        dom_mask = _DomainSafeDivide().__call__(self._data, other_data)
         other_mask = getmask(other)
         new_mask = mask_or(other_mask, dom_mask)
         # The following 3 lines control the domain filling
@@ -1700,14 +1700,14 @@
     An exception is raised if ``out`` is not None and not of the same type as self.
         """
         if out is None:
-            d = self.filled(True).any(axis=axis).view(type(self))
+            d = self.filled(False).any(axis=axis).view(type(self))
             if d.ndim > 0:
                 d.__setmask__(self._mask.all(axis))
             return d
         elif type(out) is not type(self):
             raise TypeError("The external array should have a type %s (got %s instead)" %\
                             (type(self), type(out)))
-        self.filled(True).any(axis=axis, out=out)
+        self.filled(False).any(axis=axis, out=out)
         if out.ndim:
             out.__setmask__(self._mask.all(axis))
         return out
@@ -2934,4 +2934,25 @@
     #
     z = empty(3,)
     mmys.all(0, out=z)
+    
+    if 1:
+        x = numpy.array([[ 0.13,  0.26,  0.90],
+                     [ 0.28,  0.33,  0.63],
+                     [ 0.31,  0.87,  0.70]])
+        m = numpy.array([[ True, False, False],
+                     [False, False, False],
+                     [True,  True, False]], dtype=numpy.bool_)
+        mx = masked_array(x, mask=m)
+        xbig = numpy.array([[False, False,  True],
+                        [False, False,  True],
+                        [False,  True,  True]], dtype=numpy.bool_)
+        mxbig = (mx > 0.5)
+        mxsmall = (mx < 0.5)
+        #
+        assert (mxbig.all()==False)
+        assert (mxbig.any()==True)
+        assert_equal(mxbig.all(0),[False, False, True])
+        assert_equal(mxbig.all(1), [False, False, True])
+        assert_equal(mxbig.any(0),[False, False, True])
+        assert_equal(mxbig.any(1), [True, True, True])
     
\ No newline at end of file

Modified: trunk/scipy/sandbox/maskedarray/tests/test_subclassing.py
===================================================================
--- trunk/scipy/sandbox/maskedarray/tests/test_subclassing.py	2007-10-04 17:41:49 UTC (rev 3411)
+++ trunk/scipy/sandbox/maskedarray/tests/test_subclassing.py	2007-10-04 17:43:51 UTC (rev 3412)
@@ -49,7 +49,9 @@
         SubArray.__array_finalize__(self, obj) 
         return
     def _get_series(self):
-        return self.view(MaskedArray)
+        _view = self.view(MaskedArray)
+        _view._sharedmask = False
+        return _view
     _series = property(fget=_get_series)
 msubarray = MSubArray
 
@@ -63,7 +65,9 @@
         MaskedArray.__array_finalize__(self,obj)
         return     
     def _get_series(self):
-        return self.view(MaskedArray)
+        _view =  self.view(MaskedArray)
+        _view._sharedmask = False
+        return _view
     _series = property(fget=_get_series)
 mmatrix = MMatrix 
         




More information about the Scipy-svn mailing list