1
1
from __future__ import annotations
2
2
3
3
from ._dtypes import (
4
- _floating_dtypes ,
4
+ _real_floating_dtypes ,
5
+ _real_numeric_dtypes ,
5
6
_numeric_dtypes ,
6
7
)
7
8
from ._array_object import Array
8
- from ._creation_functions import asarray
9
9
from ._dtypes import float32 , float64 , complex64 , complex128
10
10
11
11
from typing import TYPE_CHECKING , Optional , Tuple , Union
@@ -23,8 +23,8 @@ def max(
23
23
axis : Optional [Union [int , Tuple [int , ...]]] = None ,
24
24
keepdims : bool = False ,
25
25
) -> Array :
26
- if x .dtype not in _numeric_dtypes :
27
- raise TypeError ("Only numeric dtypes are allowed in max" )
26
+ if x .dtype not in _real_numeric_dtypes :
27
+ raise TypeError ("Only real numeric dtypes are allowed in max" )
28
28
return Array ._new (np .max (x ._array , axis = axis , keepdims = keepdims ))
29
29
30
30
@@ -35,8 +35,8 @@ def mean(
35
35
axis : Optional [Union [int , Tuple [int , ...]]] = None ,
36
36
keepdims : bool = False ,
37
37
) -> Array :
38
- if x .dtype not in _floating_dtypes :
39
- raise TypeError ("Only floating-point dtypes are allowed in mean" )
38
+ if x .dtype not in _real_floating_dtypes :
39
+ raise TypeError ("Only real floating-point dtypes are allowed in mean" )
40
40
return Array ._new (np .mean (x ._array , axis = axis , keepdims = keepdims ))
41
41
42
42
@@ -47,8 +47,8 @@ def min(
47
47
axis : Optional [Union [int , Tuple [int , ...]]] = None ,
48
48
keepdims : bool = False ,
49
49
) -> Array :
50
- if x .dtype not in _numeric_dtypes :
51
- raise TypeError ("Only numeric dtypes are allowed in min" )
50
+ if x .dtype not in _real_numeric_dtypes :
51
+ raise TypeError ("Only real numeric dtypes are allowed in min" )
52
52
return Array ._new (np .min (x ._array , axis = axis , keepdims = keepdims ))
53
53
54
54
@@ -82,8 +82,8 @@ def std(
82
82
keepdims : bool = False ,
83
83
) -> Array :
84
84
# Note: the keyword argument correction is different here
85
- if x .dtype not in _floating_dtypes :
86
- raise TypeError ("Only floating-point dtypes are allowed in std" )
85
+ if x .dtype not in _real_floating_dtypes :
86
+ raise TypeError ("Only real floating-point dtypes are allowed in std" )
87
87
return Array ._new (np .std (x ._array , axis = axis , ddof = correction , keepdims = keepdims ))
88
88
89
89
@@ -117,6 +117,6 @@ def var(
117
117
keepdims : bool = False ,
118
118
) -> Array :
119
119
# Note: the keyword argument correction is different here
120
- if x .dtype not in _floating_dtypes :
121
- raise TypeError ("Only floating-point dtypes are allowed in var" )
120
+ if x .dtype not in _real_floating_dtypes :
121
+ raise TypeError ("Only real floating-point dtypes are allowed in var" )
122
122
return Array ._new (np .var (x ._array , axis = axis , ddof = correction , keepdims = keepdims ))
0 commit comments