diff options
author | pierregm <pierregm@localhost> | 2009-10-09 02:17:30 +0000 |
---|---|---|
committer | pierregm <pierregm@localhost> | 2009-10-09 02:17:30 +0000 |
commit | 8cad335f8b97100df988dbb6fd5d06072c667515 (patch) | |
tree | 5eb53d599da9028fc42d31ffdd979f022268a472 /numpy/ma | |
parent | e54df63621db89eddbadc7bf0f36798ee1f79e0a (diff) | |
download | numpy-8cad335f8b97100df988dbb6fd5d06072c667515.tar.gz |
* ma.masked_equal : force the `fill_value` of the output to `value` (ticket #1253)
* lib._iotools:
- NameValidator : add the `nbfields` optional argument to validate
- add easy_dtype
* lib.io.genfromtxt :
- add the `autostrip` optional argument (ticket #1238)
- use `invalid_raise=True` as default
- use the easy_dtype mechanism (ticket #1252)
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.]) |