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 as np >>> import numpy.ma
(x, value, copy=True)
| 2114 | |
| 2115 | |
| 2116 | def masked_not_equal(x, value, copy=True): |
| 2117 | """ |
| 2118 | Mask an array where *not* equal to a given value. |
| 2119 | |
| 2120 | This function is a shortcut to ``masked_where``, with |
| 2121 | `condition` = (x != value). |
| 2122 | |
| 2123 | See Also |
| 2124 | -------- |
| 2125 | masked_where : Mask where a condition is met. |
| 2126 | |
| 2127 | Examples |
| 2128 | -------- |
| 2129 | >>> import numpy as np |
| 2130 | >>> import numpy.ma as ma |
| 2131 | >>> a = np.arange(4) |
| 2132 | >>> a |
| 2133 | array([0, 1, 2, 3]) |
| 2134 | >>> ma.masked_not_equal(a, 2) |
| 2135 | masked_array(data=[--, --, 2, --], |
| 2136 | mask=[ True, True, False, True], |
| 2137 | fill_value=999999) |
| 2138 | |
| 2139 | """ |
| 2140 | return masked_where(not_equal(x, value), x, copy=copy) |
| 2141 | |
| 2142 | |
| 2143 | def masked_equal(x, value, copy=True): |
searching dependent graphs…