[Numpy-svn] r6357 - in branches/1.2.x/numpy/ma: . tests
numpy-svn at scipy.org
numpy-svn at scipy.org
Tue Feb 10 20:53:09 EST 2009
Author: pierregm
Date: 2009-02-10 19:52:37 -0600 (Tue, 10 Feb 2009)
New Revision: 6357
Modified:
branches/1.2.x/numpy/ma/core.py
branches/1.2.x/numpy/ma/tests/test_core.py
Log:
* MaskedArray.__array_wrap__ : forces the domain (if any) to a ndarray (fill with True)
Modified: branches/1.2.x/numpy/ma/core.py
===================================================================
--- branches/1.2.x/numpy/ma/core.py 2009-02-11 01:51:28 UTC (rev 6356)
+++ branches/1.2.x/numpy/ma/core.py 2009-02-11 01:52:37 UTC (rev 6357)
@@ -1577,10 +1577,11 @@
# Get the domain mask................
domain = ufunc_domain.get(func, None)
if domain is not None:
+ # Take the domain, and make sure it's a ndarray
if len(args) > 2:
- d = reduce(domain, args)
+ d = filled(reduce(domain, args), True)
else:
- d = domain(*args)
+ d = filled(domain(*args), True)
# Fill the result where the domain is wrong
try:
# Binary domain: take the last value
Modified: branches/1.2.x/numpy/ma/tests/test_core.py
===================================================================
--- branches/1.2.x/numpy/ma/tests/test_core.py 2009-02-11 01:51:28 UTC (rev 6356)
+++ branches/1.2.x/numpy/ma/tests/test_core.py 2009-02-11 01:52:37 UTC (rev 6357)
@@ -826,7 +826,6 @@
self.failUnless(output[0] is masked)
-
def test_numpyarithmetics(self):
"Check that the mask is not back-propagated when using numpy functions"
a = masked_array([-1, 0, 1, 2, 3], mask=[0, 0, 0, 0, 1])
@@ -1143,7 +1142,17 @@
self.failUnless(amask.max(1)[0].mask)
self.failUnless(amask.min(1)[0].mask)
+ def test_ndarray_mask(self):
+ "Check that the mask of the result is a ndarray (not a MaskedArray...)"
+ a = masked_array([-1, 0, 1, 2, 3], mask=[0, 0, 0, 0, 1])
+ test = np.sqrt(a)
+ control = masked_array([-1, 0, 1, np.sqrt(2), -1],
+ mask=[1, 0, 0, 0, 1])
+ assert_equal(test, control)
+ assert_equal(test.mask, control.mask)
+ self.failUnless(not isinstance(test.mask, MaskedArray))
+
#------------------------------------------------------------------------------
class TestMaskedArrayInPlaceArithmetics(TestCase):
More information about the Numpy-svn
mailing list