Array API compatible wrapper for :py:func:`np.left_shift `. See its docstring for more information.
(x1: Array, x2: Array, /)
| 147 | |
| 148 | # Note: the function name is different here |
| 149 | def 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 |