3
3
from ._dtypes import (
4
4
_boolean_dtypes ,
5
5
_floating_dtypes ,
6
+ _real_floating_dtypes ,
6
7
_complex_floating_dtypes ,
7
8
_integer_dtypes ,
8
9
_integer_or_boolean_dtypes ,
10
+ _real_numeric_dtypes ,
9
11
_numeric_dtypes ,
10
12
_result_type ,
11
13
)
@@ -106,8 +108,8 @@ def atan2(x1: Array, x2: Array, /) -> Array:
106
108
107
109
See its docstring for more information.
108
110
"""
109
- if x1 .dtype not in _floating_dtypes or x2 .dtype not in _floating_dtypes :
110
- raise TypeError ("Only floating-point dtypes are allowed in atan2" )
111
+ if x1 .dtype not in _real_floating_dtypes or x2 .dtype not in _real_floating_dtypes :
112
+ raise TypeError ("Only real floating-point dtypes are allowed in atan2" )
111
113
# Call result type here just to raise on disallowed type combinations
112
114
_result_type (x1 .dtype , x2 .dtype )
113
115
x1 , x2 = Array ._normalize_two_args (x1 , x2 )
@@ -231,8 +233,8 @@ def ceil(x: Array, /) -> Array:
231
233
232
234
See its docstring for more information.
233
235
"""
234
- if x .dtype not in _numeric_dtypes :
235
- raise TypeError ("Only numeric dtypes are allowed in ceil" )
236
+ if x .dtype not in _real_numeric_dtypes :
237
+ raise TypeError ("Only real numeric dtypes are allowed in ceil" )
236
238
if x .dtype in _integer_dtypes :
237
239
# Note: The return dtype of ceil is the same as the input
238
240
return x
@@ -326,8 +328,8 @@ def floor(x: Array, /) -> Array:
326
328
327
329
See its docstring for more information.
328
330
"""
329
- if x .dtype not in _numeric_dtypes :
330
- raise TypeError ("Only numeric dtypes are allowed in floor" )
331
+ if x .dtype not in _real_numeric_dtypes :
332
+ raise TypeError ("Only real numeric dtypes are allowed in floor" )
331
333
if x .dtype in _integer_dtypes :
332
334
# Note: The return dtype of floor is the same as the input
333
335
return x
@@ -340,8 +342,8 @@ def floor_divide(x1: Array, x2: Array, /) -> Array:
340
342
341
343
See its docstring for more information.
342
344
"""
343
- if x1 .dtype not in _numeric_dtypes or x2 .dtype not in _numeric_dtypes :
344
- raise TypeError ("Only numeric dtypes are allowed in floor_divide" )
345
+ if x1 .dtype not in _real_numeric_dtypes or x2 .dtype not in _real_numeric_dtypes :
346
+ raise TypeError ("Only real numeric dtypes are allowed in floor_divide" )
345
347
# Call result type here just to raise on disallowed type combinations
346
348
_result_type (x1 .dtype , x2 .dtype )
347
349
x1 , x2 = Array ._normalize_two_args (x1 , x2 )
@@ -354,8 +356,8 @@ def greater(x1: Array, x2: Array, /) -> Array:
354
356
355
357
See its docstring for more information.
356
358
"""
357
- if x1 .dtype not in _numeric_dtypes or x2 .dtype not in _numeric_dtypes :
358
- raise TypeError ("Only numeric dtypes are allowed in greater" )
359
+ if x1 .dtype not in _real_numeric_dtypes or x2 .dtype not in _real_numeric_dtypes :
360
+ raise TypeError ("Only real numeric dtypes are allowed in greater" )
359
361
# Call result type here just to raise on disallowed type combinations
360
362
_result_type (x1 .dtype , x2 .dtype )
361
363
x1 , x2 = Array ._normalize_two_args (x1 , x2 )
@@ -368,8 +370,8 @@ def greater_equal(x1: Array, x2: Array, /) -> Array:
368
370
369
371
See its docstring for more information.
370
372
"""
371
- if x1 .dtype not in _numeric_dtypes or x2 .dtype not in _numeric_dtypes :
372
- raise TypeError ("Only numeric dtypes are allowed in greater_equal" )
373
+ if x1 .dtype not in _real_numeric_dtypes or x2 .dtype not in _real_numeric_dtypes :
374
+ raise TypeError ("Only real numeric dtypes are allowed in greater_equal" )
373
375
# Call result type here just to raise on disallowed type combinations
374
376
_result_type (x1 .dtype , x2 .dtype )
375
377
x1 , x2 = Array ._normalize_two_args (x1 , x2 )
@@ -426,8 +428,8 @@ def less(x1: Array, x2: Array, /) -> Array:
426
428
427
429
See its docstring for more information.
428
430
"""
429
- if x1 .dtype not in _numeric_dtypes or x2 .dtype not in _numeric_dtypes :
430
- raise TypeError ("Only numeric dtypes are allowed in less" )
431
+ if x1 .dtype not in _real_numeric_dtypes or x2 .dtype not in _real_numeric_dtypes :
432
+ raise TypeError ("Only real numeric dtypes are allowed in less" )
431
433
# Call result type here just to raise on disallowed type combinations
432
434
_result_type (x1 .dtype , x2 .dtype )
433
435
x1 , x2 = Array ._normalize_two_args (x1 , x2 )
@@ -440,8 +442,8 @@ def less_equal(x1: Array, x2: Array, /) -> Array:
440
442
441
443
See its docstring for more information.
442
444
"""
443
- if x1 .dtype not in _numeric_dtypes or x2 .dtype not in _numeric_dtypes :
444
- raise TypeError ("Only numeric dtypes are allowed in less_equal" )
445
+ if x1 .dtype not in _real_numeric_dtypes or x2 .dtype not in _real_numeric_dtypes :
446
+ raise TypeError ("Only real numeric dtypes are allowed in less_equal" )
445
447
# Call result type here just to raise on disallowed type combinations
446
448
_result_type (x1 .dtype , x2 .dtype )
447
449
x1 , x2 = Array ._normalize_two_args (x1 , x2 )
@@ -498,8 +500,8 @@ def logaddexp(x1: Array, x2: Array) -> Array:
498
500
499
501
See its docstring for more information.
500
502
"""
501
- if x1 .dtype not in _floating_dtypes or x2 .dtype not in _floating_dtypes :
502
- raise TypeError ("Only floating-point dtypes are allowed in logaddexp" )
503
+ if x1 .dtype not in _real_floating_dtypes or x2 .dtype not in _real_floating_dtypes :
504
+ raise TypeError ("Only real floating-point dtypes are allowed in logaddexp" )
503
505
# Call result type here just to raise on disallowed type combinations
504
506
_result_type (x1 .dtype , x2 .dtype )
505
507
x1 , x2 = Array ._normalize_two_args (x1 , x2 )
@@ -639,8 +641,8 @@ def remainder(x1: Array, x2: Array, /) -> Array:
639
641
640
642
See its docstring for more information.
641
643
"""
642
- if x1 .dtype not in _numeric_dtypes or x2 .dtype not in _numeric_dtypes :
643
- raise TypeError ("Only numeric dtypes are allowed in remainder" )
644
+ if x1 .dtype not in _real_numeric_dtypes or x2 .dtype not in _real_numeric_dtypes :
645
+ raise TypeError ("Only real numeric dtypes are allowed in remainder" )
644
646
# Call result type here just to raise on disallowed type combinations
645
647
_result_type (x1 .dtype , x2 .dtype )
646
648
x1 , x2 = Array ._normalize_two_args (x1 , x2 )
@@ -755,8 +757,8 @@ def trunc(x: Array, /) -> Array:
755
757
756
758
See its docstring for more information.
757
759
"""
758
- if x .dtype not in _numeric_dtypes :
759
- raise TypeError ("Only numeric dtypes are allowed in trunc" )
760
+ if x .dtype not in _real_numeric_dtypes :
761
+ raise TypeError ("Only real numeric dtypes are allowed in trunc" )
760
762
if x .dtype in _integer_dtypes :
761
763
# Note: The return dtype of trunc is the same as the input
762
764
return x
0 commit comments