diff options
author | Mark Wiebe <mwiebe@enthought.com> | 2011-06-06 11:44:08 -0500 |
---|---|---|
committer | Mark Wiebe <mwiebe@enthought.com> | 2011-06-22 09:09:07 -0500 |
commit | a72132dce48e7c2b0f514258e05a40ab78850162 (patch) | |
tree | b383ae9fa6aeae733cd1768a9849e1c04676ace7 /numpy | |
parent | c149545d31e9fb9ba28075fc0a58cb836eab0f8a (diff) | |
download | numpy-a72132dce48e7c2b0f514258e05a40ab78850162.tar.gz |
ENH: ma: Fix up ma and its tests to work with default same_kind casting
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/ma/core.py | 5 | ||||
-rw-r--r-- | numpy/ma/tests/test_core.py | 4 |
2 files changed, 5 insertions, 4 deletions
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 |