From a72132dce48e7c2b0f514258e05a40ab78850162 Mon Sep 17 00:00:00 2001 From: Mark Wiebe Date: Mon, 6 Jun 2011 11:44:08 -0500 Subject: ENH: ma: Fix up ma and its tests to work with default same_kind casting --- numpy/ma/core.py | 5 +++-- numpy/ma/tests/test_core.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'numpy/ma') diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 2cb888d55..50c60cd9d 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -4771,7 +4771,7 @@ class MaskedArray(ndarray): if dvar is not masked: dvar = sqrt(dvar) if out is not None: - out **= 0.5 + np.power(out, 0.5, out=out, casting='unsafe') return out return dvar std.__doc__ = np.std.__doc__ @@ -5207,7 +5207,8 @@ class MaskedArray(ndarray): result -= self.min(axis=axis, fill_value=fill_value) return result out.flat = self.max(axis=axis, out=out, fill_value=fill_value) - out -= self.min(axis=axis, fill_value=fill_value) + min_value = self.min(axis=axis, fill_value=fill_value) + np.subtract(out, min_value, out=out, casting='unsafe') return out def take(self, indices, axis=None, out=None, mode='raise'): diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 2a2a76c24..b4ec3e540 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -1031,7 +1031,7 @@ class TestMaskedArrayArithmetic(TestCase): def test_noshrinking(self): "Check that we don't shrink a mask when not wanted" # Binary operations - a = masked_array([1, 2, 3], mask=[False, False, False], shrink=False) + a = masked_array([1., 2., 3.], mask=[False, False, False], shrink=False) b = a + 1 assert_equal(b.mask, [0, 0, 0]) # In place binary operation @@ -1646,7 +1646,7 @@ class TestMaskedArrayInPlaceArithmetics(TestCase): """Test of inplace additions""" (x, y, xm) = self.intdata m = xm.mask - a = arange(10, dtype=float) + a = arange(10, dtype=np.int16) a[-1] = masked x += a xm += a -- cgit v1.2.1