MCPcopy Create free account
hub / github.com/numpy/numpy / bitwise_right_shift

Function bitwise_right_shift

numpy/array_api/_elementwise_functions.py:196–210  ·  view source on GitHub ↗

Array API compatible wrapper for :py:func:`np.right_shift `. See its docstring for more information.

(x1: Array, x2: Array, /)

Source from the content-addressed store, hash-verified

194
195# Note: the function name is different here
196def 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
213def bitwise_xor(x1: Array, x2: Array, /) -> Array:

Callers 1

test_bitwise_shift_errorFunction · 0.85

Calls 4

_result_typeFunction · 0.85
_normalize_two_argsMethod · 0.80
_newMethod · 0.80
anyMethod · 0.45

Tested by 1

test_bitwise_shift_errorFunction · 0.68