Mask an array where `not` equal to a given value. This function is a shortcut to ``masked_where``, with `condition` = (x != value). See Also -------- masked_where : Mask where a condition is met. Examples -------- >>> import numpy.ma as ma >>> a = np.arang
(x, value, copy=True)
| 2052 | |
| 2053 | |
| 2054 | def masked_not_equal(x, value, copy=True): |
| 2055 | """ |
| 2056 | Mask an array where `not` equal to a given value. |
| 2057 | |
| 2058 | This function is a shortcut to ``masked_where``, with |
| 2059 | `condition` = (x != value). |
| 2060 | |
| 2061 | See Also |
| 2062 | -------- |
| 2063 | masked_where : Mask where a condition is met. |
| 2064 | |
| 2065 | Examples |
| 2066 | -------- |
| 2067 | >>> import numpy.ma as ma |
| 2068 | >>> a = np.arange(4) |
| 2069 | >>> a |
| 2070 | array([0, 1, 2, 3]) |
| 2071 | >>> ma.masked_not_equal(a, 2) |
| 2072 | masked_array(data=[--, --, 2, --], |
| 2073 | mask=[ True, True, False, True], |
| 2074 | fill_value=999999) |
| 2075 | |
| 2076 | """ |
| 2077 | return masked_where(not_equal(x, value), x, copy=copy) |
| 2078 | |
| 2079 | |
| 2080 | def masked_equal(x, value, copy=True): |