8000 ENH: ma: Fix up ma and its tests to work with default same_kind casting · numpy/numpy@a72132d · GitHub
[go: up one dir, main page]

Skip to content

Commit a72132d

Browse files
author
Mark Wiebe
committed
ENH: ma: Fix up ma and its tests to work with default same_kind casting
1 parent c149545 commit a72132d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

numpy/ma/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4771,7 +4771,7 @@ def std(self, axis=None, dtype=None, out=None, ddof=0):
47714771
if dvar is not masked:
47724772
dvar = sqrt(dvar)
47734773
if out is not None:
4774-
out **= 0.5
4774+
np.power(out, 0.5, out=out, casting='unsafe')
47754775
return out
47764776
return dvar
47774777
std.__doc__ = np.std.__doc__
@@ -5207,7 +5207,8 @@ def ptp(self, axis=None, out=None, fill_value=None):
52075207
result -= self.min(axis=axis, fill_value=fill_value)
52085208
return result
52095209
out.flat = self.max(axis=axis, out=out, fill_value=fill_value)
5210-
out -= self.min(axis=axis, fill_value=fill_value)
5210+
min_value = self.min(axis=axis, fill_value=fill_value)
5211+
np.subtract(out, min_value, out=out, casting='unsafe')
52115212
return out
52125213

52135214
def take(self, indices, axis=None, out=None, mode='raise'):

numpy/ma/tests/test_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ def test_domained_binops_d2D(self):
10311031
def test_noshrinking(self):
10321032
"Check that we don't shrink a mask when not wanted"
10331033
# Binary operations
1034-
a = masked_array([1, 2, 3], mask=[False, False, False], shrink=False)
1034+
a = masked_array([1., 2., 3.], mask=[False, False, False], shrink=False)
10351035
b = a + 1
10361036
assert_equal(b.mask, [0, 0, 0])
10371037
# In place binary operation
@@ -1646,7 +1646,7 @@ def test_inplace_addition_array(self):
16461646
"""Test of inplace additions"""
16471647
(x, y, xm) = self.intdata
16481648
m = xm.mask
1649-
a = arange(10, dtype=float)
1649+
a = arange(10, dtype=np.int16)
16501650
a[-1] = masked
16511651
x += a
16521652
xm += a

0 commit comments

Comments
 (0)
0