summaryrefslogtreecommitdiff
path: root/numpy/_array_api/_elementwise_functions.py
diff options
context:
space:
mode:
authorAaron Meurer <asmeurer@gmail.com>2021-07-09 18:08:22 -0600
committerAaron Meurer <asmeurer@gmail.com>2021-07-09 18:08:22 -0600
commit5217236995f839250a148e533f4395007288cc24 (patch)
treef1797447fc0408bda58c78649c2113569dca2dfa /numpy/_array_api/_elementwise_functions.py
parent6765494edee2b90f239ae622abb5f3a7d218aa84 (diff)
downloadnumpy-5217236995f839250a148e533f4395007288cc24.tar.gz
Make the array API left and right shift do type promotion
The spec previously said it should return the type of the left argument, but this was changed to do type promotion to be consistent with all the other elementwise functions/operators.
Diffstat (limited to 'numpy/_array_api/_elementwise_functions.py')
-rw-r--r--numpy/_array_api/_elementwise_functions.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/numpy/_array_api/_elementwise_functions.py b/numpy/_array_api/_elementwise_functions.py
index 8dedc77fb..0d955b614 100644
--- a/numpy/_array_api/_elementwise_functions.py
+++ b/numpy/_array_api/_elementwise_functions.py
@@ -136,10 +136,7 @@ def bitwise_left_shift(x1: Array, x2: Array, /) -> Array:
# Note: bitwise_left_shift is only defined for x2 nonnegative.
if np.any(x2._array < 0):
raise ValueError('bitwise_left_shift(x1, x2) is only defined for x2 >= 0')
- # Note: The spec requires the return dtype of bitwise_left_shift to be the
- # same as the first argument. np.left_shift() returns a type that is the
- # type promotion of the two input types.
- return Array._new(np.left_shift(x1._array, x2._array).astype(x1.dtype))
+ return Array._new(np.left_shift(x1._array, x2._array))
# Note: the function name is different here
def bitwise_invert(x: Array, /) -> Array:
@@ -176,10 +173,7 @@ def bitwise_right_shift(x1: Array, x2: Array, /) -> Array:
# Note: bitwise_right_shift is only defined for x2 nonnegative.
if np.any(x2._array < 0):
raise ValueError('bitwise_right_shift(x1, x2) is only defined for x2 >= 0')
- # Note: The spec requires the return dtype of bitwise_left_shift to be the
- # same as the first argument. np.left_shift() returns a type that is the
- # type promotion of the two input types.
- return Array._new(np.right_shift(x1._array, x2._array).astype(x1.dtype))
+ return Array._new(np.right_shift(x1._array, x2._array))
def bitwise_xor(x1: Array, x2: Array, /) -> Array:
"""