@@ -42,12 +42,17 @@ class void:
4242# and this is why we let int32 be a subclass of int64; and similarly for float32 and float64
4343# the same logic applies when adding unsigned and signed values (uint + int -> int)
4444
45+ class complex128 (void , int ):
46+ def __complex__ (self ) -> complex : ...
47+
48+ class complex64 (complex128 ): ...
49+
4550# this would be the correct definition, but it makes `int` conflict with `float`
4651# class float64(void, float): ...
47- class float64 (void , int ):
52+ class float64 (complex128 ):
4853 def __float__ (self ) -> float : ...
4954
50- class float32 (float64 ): ...
55+ class float32 (float64 , complex64 ): ...
5156class float16 (float32 ): ...
5257
5358floating = float64
@@ -70,6 +75,8 @@ integer = int64
7075_DType = TypeVar (
7176 "_DType" ,
7277 bool_ ,
78+ complex64 ,
79+ complex128 ,
7380 float16 ,
7481 float32 ,
7582 float64 ,
@@ -87,6 +94,8 @@ _DType = TypeVar(
8794_DType2 = TypeVar (
8895 "_DType2" ,
8996 bool_ ,
97+ complex64 ,
98+ complex128 ,
9099 float16 ,
91100 float32 ,
92101 float64 ,
@@ -110,7 +119,7 @@ _ScalarLike = Union[_DType, str, int, float]
110119_ConditionType = Union [ndarray [bool_ ], bool_ , bool ]
111120newaxis : None = ...
112121
113- _AnyNum = Union [int , float , bool ]
122+ _AnyNum = Union [int , float , bool , complex ]
114123# generic types that are only allowed to take on dtype values
115124
116125_Float = TypeVar ("_Float" , float16 , float32 , float64 )
@@ -391,7 +400,7 @@ class ndarray(Generic[_DType]):
391400 @overload
392401 def __radd__ (self , value : _DType ) -> ndarray [_DType ]: ...
393402 @overload
394- def __radd__ (self , value : float ) -> ndarray [_DType ]: ...
403+ def __radd__ (self , value : float ) -> ndarray [_DType2 ]: ...
395404 def __rand__ (self , value : object ) -> ndarray [_DType ]: ...
396405 def __rdivmod__ (self , value : object ) -> Tuple [ndarray [_DType ], ndarray [_DType ]]: ...
397406 def __rfloordiv__ (self , value : object ) -> ndarray [_DType ]: ...
@@ -506,6 +515,8 @@ def array(object: _NestedList[int]) -> ndarray[int64]: ...
506515@overload
507516def array (object : _NestedList [float ]) -> ndarray [float64 ]: ...
508517@overload
518+ def array (object : _NestedList [complex ]) -> ndarray [complex64 ]: ...
519+ @overload
509520def array (object : _NestedList [str ]) -> ndarray [str_ ]: ...
510521@overload
511522def array (object : str ) -> ndarray [str_ ]: ...
0 commit comments