diff options
Diffstat (limited to 'numpy/ma')
-rw-r--r-- | numpy/ma/core.py | 4 | ||||
-rw-r--r-- | numpy/ma/tests/test_core.py | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index d32385493..cee884e9d 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -1963,7 +1963,9 @@ def masked_equal(x, value, copy=True): # c = umath.equal(d, value) # m = mask_or(c, getmask(x)) # return array(d, mask=m, copy=copy) - return masked_where(equal(x, value), x, copy=copy) + output = masked_where(equal(x, value), x, copy=copy) + output.fill_value = value + return output def masked_inside(x, v1, v2, copy=True): diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 61f315753..e3447b546 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -2591,6 +2591,12 @@ class TestMaskedArrayFunctions(TestCase): assert_equal(mx, x) assert_equal(mx._mask, [1,1,0]) + def test_masked_equal_fill_value(self): + x = [1, 2, 3] + mx = masked_equal(x, 3) + assert_equal(mx._mask, [0, 0, 1]) + assert_equal(mx.fill_value, 3) + def test_masked_where_condition(self): "Tests masking functions." x = array([1.,2.,3.,4.,5.]) |