diff options
| author | Chiara Marmo <marmochiaskl@gmail.com> | 2022-10-13 11:38:13 -1000 |
|---|---|---|
| committer | Chiara Marmo <marmochiaskl@gmail.com> | 2022-10-13 11:41:53 -1000 |
| commit | 7a85f04e06d87440fe9a33f95eea2860917ddbbc (patch) | |
| tree | 5dbe4c79b49b45f045845553baa34d5d9c75a4c8 /numpy | |
| parent | 6db3236cd81c107d752d8ef5fb411f26bf8b7255 (diff) | |
| download | numpy-7a85f04e06d87440fe9a33f95eea2860917ddbbc.tar.gz | |
Clarify docstring of masked_values
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/ma/core.py | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index ba01f3e2e..0eca798de 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -2085,6 +2085,8 @@ def masked_equal(x, value, copy=True): `condition` = (x == value). For floating point arrays, consider using ``masked_values(x, value)``. + The fill_value is set to `value`. + See Also -------- masked_where : Mask where a condition is met. @@ -2303,25 +2305,17 @@ def masked_values(x, value, rtol=1e-5, atol=1e-8, copy=True, shrink=True): Note that `mask` is set to ``nomask`` if possible. - >>> ma.masked_values(x, 1.5) + >>> ma.masked_values(x, 2.1) masked_array(data=[1. , 1.1, 2. , 1.1, 3. ], mask=False, - fill_value=1.5) + fill_value=2.1) - For integers, the fill value will be different in general to the - result of ``masked_equal``. + Unlike `masked_equal`, `masked_values` can perform approximate equalities. - >>> x = np.arange(5) - >>> x - array([0, 1, 2, 3, 4]) - >>> ma.masked_values(x, 2) - masked_array(data=[0, 1, --, 3, 4], + >>> ma.masked_values(x, 2.1, atol=1e-1) + masked_array(data=[1.0, 1.1, --, 1.1, 3.0], mask=[False, False, True, False, False], - fill_value=2) - >>> ma.masked_equal(x, 2) - masked_array(data=[0, 1, --, 3, 4], - mask=[False, False, True, False, False], - fill_value=2) + fill_value=2.1) """ xnew = filled(x, value) |
