Shift the bits of an integer to the right. This is the masked array version of `numpy.right_shift`, for details see that function. See Also -------- numpy.right_shift Examples -------- >>> import numpy.ma as ma >>> x = [11, 3, 8, 1] >>> mask = [0, 0, 0
(a, n)
| 7224 | |
| 7225 | |
| 7226 | def right_shift(a, n): |
| 7227 | """ |
| 7228 | Shift the bits of an integer to the right. |
| 7229 | |
| 7230 | This is the masked array version of `numpy.right_shift`, for details |
| 7231 | see that function. |
| 7232 | |
| 7233 | See Also |
| 7234 | -------- |
| 7235 | numpy.right_shift |
| 7236 | |
| 7237 | Examples |
| 7238 | -------- |
| 7239 | >>> import numpy.ma as ma |
| 7240 | >>> x = [11, 3, 8, 1] |
| 7241 | >>> mask = [0, 0, 0, 1] |
| 7242 | >>> masked_x = ma.masked_array(x, mask) |
| 7243 | >>> masked_x |
| 7244 | masked_array(data=[11, 3, 8, --], |
| 7245 | mask=[False, False, False, True], |
| 7246 | fill_value=999999) |
| 7247 | >>> ma.right_shift(masked_x,1) |
| 7248 | masked_array(data=[5, 1, 4, --], |
| 7249 | mask=[False, False, False, True], |
| 7250 | fill_value=999999) |
| 7251 | |
| 7252 | """ |
| 7253 | m = getmask(a) |
| 7254 | if m is nomask: |
| 7255 | d = umath.right_shift(filled(a), n) |
| 7256 | return masked_array(d) |
| 7257 | else: |
| 7258 | d = umath.right_shift(filled(a, 0), n) |
| 7259 | return masked_array(d, mask=m) |
| 7260 | |
| 7261 | |
| 7262 | def put(a, indices, values, mode='raise'): |
no test coverage detected