Array API compatible wrapper for :py:func:`np.right_shift `. See its docstring for more information.
(x1: Array, x2: Array, /)
| 194 | |
| 195 | # Note: the function name is different here |
| 196 | def bitwise_right_shift(x1: Array, x2: Array, /) -> Array: |
| 197 | """ |
| 198 | Array API compatible wrapper for :py:func:`np.right_shift <numpy.right_shift>`. |
| 199 | |
| 200 | See its docstring for more information. |
| 201 | """ |
| 202 | if x1.dtype not in _integer_dtypes or x2.dtype not in _integer_dtypes: |
| 203 | raise TypeError("Only integer dtypes are allowed in bitwise_right_shift") |
| 204 | # Call result type here just to raise on disallowed type combinations |
| 205 | _result_type(x1.dtype, x2.dtype) |
| 206 | x1, x2 = Array._normalize_two_args(x1, x2) |
| 207 | # Note: bitwise_right_shift is only defined for x2 nonnegative. |
| 208 | if np.any(x2._array < 0): |
| 209 | raise ValueError("bitwise_right_shift(x1, x2) is only defined for x2 >= 0") |
| 210 | return Array._new(np.right_shift(x1._array, x2._array)) |
| 211 | |
| 212 | |
| 213 | def bitwise_xor(x1: Array, x2: Array, /) -> Array: |