Skip to content

Commit 5cf028c

Browse files
committed
Fix NumPy 1.26 type promotion in copysign
1 parent c721f3d commit 5cf028c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

array_api_strict/_elementwise_functions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ def copysign(x1: Array, x2: Array, /) -> Array:
328328
"""
329329
if x1.dtype not in _real_numeric_dtypes or x2.dtype not in _real_numeric_dtypes:
330330
raise TypeError("Only real numeric dtypes are allowed in copysign")
331+
# Call result type here just to raise on disallowed type combinations
332+
_result_type(x1.dtype, x2.dtype)
333+
x1, x2 = Array._normalize_two_args(x1, x2)
331334
return Array._new(np.copysign(x1._array, x2._array))
332335

333336
def cos(x: Array, /) -> Array:

0 commit comments

Comments
 (0)