[Numpy-svn] r8214 - trunk/numpy/ma

numpy-svn@scip... numpy-svn@scip...
Sat Feb 20 20:50:49 CST 2010


Author: ptvirtan
Date: 2010-02-20 20:50:49 -0600 (Sat, 20 Feb 2010)
New Revision: 8214

Modified:
   trunk/numpy/ma/core.py
Log:
3K: ENH: ma: implement data-preserving __ifloordiv__ and __itruediv__

Modified: trunk/numpy/ma/core.py
===================================================================
--- trunk/numpy/ma/core.py	2010-02-21 02:50:34 UTC (rev 8213)
+++ trunk/numpy/ma/core.py	2010-02-21 02:50:49 UTC (rev 8214)
@@ -3726,6 +3726,36 @@
         self._mask |= new_mask
         ndarray.__idiv__(self._data, np.where(self._mask, 1, other_data))
         return self
+    #....
+    def __ifloordiv__(self, other):
+        "Floor divide self by other in-place."
+        other_data = getdata(other)
+        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
+        if dom_mask.any():
+            (_, fval) = ufunc_fills[np.floor_divide]
+            other_data = np.where(dom_mask, fval, other_data)
+#        self._mask = mask_or(self._mask, new_mask)
+        self._mask |= new_mask
+        ndarray.__ifloordiv__(self._data, np.where(self._mask, 1, other_data))
+        return self
+    #....
+    def __itruediv__(self, other):
+        "True divide self by other in-place."
+        other_data = getdata(other)
+        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
+        if dom_mask.any():
+            (_, fval) = ufunc_fills[np.true_divide]
+            other_data = np.where(dom_mask, fval, other_data)
+#        self._mask = mask_or(self._mask, new_mask)
+        self._mask |= new_mask
+        ndarray.__itruediv__(self._data, np.where(self._mask, 1, other_data))
+        return self
     #...
     def __ipow__(self, other):
         "Raise self to the power other, in place."



More information about the Numpy-svn mailing list