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

Function bitwise_left_shift

numpy/array_api/_elementwise_functions.py:149–163  ·  view source on GitHub ↗

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

(x1: Array, x2: Array, /)

Source from the content-addressed store, hash-verified

147
148# Note: the function name is different here
149def bitwise_left_shift(x1: Array, x2: Array, /) -> Array:
150 """
151 Array API compatible wrapper for :py:func:`np.left_shift <numpy.left_shift>`.
152
153 See its docstring for more information.
154 """
155 if x1.dtype not in _integer_dtypes or x2.dtype not in _integer_dtypes:
156 raise TypeError("Only integer dtypes are allowed in bitwise_left_shift")
157 # Call result type here just to raise on disallowed type combinations
158 _result_type(x1.dtype, x2.dtype)
159 x1, x2 = Array._normalize_two_args(x1, x2)
160 # Note: bitwise_left_shift is only defined for x2 nonnegative.
161 if np.any(x2._array < 0):
162 raise ValueError("bitwise_left_shift(x1, x2) is only defined for x2 >= 0")
163 return Array._new(np.left_shift(x1._array, x2._array))
164
165
166# Note: the function name is different here

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