@@ -1760,11 +1760,15 @@ _DType = TypeVar("_DType", bound=dtype[Any])
1760
1760
_DType_co = TypeVar ("_DType_co" , covariant = True , bound = dtype [Any ])
1761
1761
_FlexDType = TypeVar ("_FlexDType" , bound = dtype [flexible ])
1762
1762
1763
+ _IntegralArrayT = TypeVar ("_IntegralArrayT" , bound = NDArray [integer [Any ] | np .bool | object_ ])
1764
+ _RealArrayT = TypeVar ("_RealArrayT" , bound = NDArray [floating [Any ] | integer [Any ] | timedelta64 | np .bool | object_ ])
1765
+ _NumericArrayT = TypeVar ("_NumericArrayT" , bound = NDArray [number [Any ] | timedelta64 | object_ ])
1766
+
1763
1767
_Shape1D : TypeAlias = tuple [int ]
1764
1768
_Shape2D : TypeAlias = tuple [int , int ]
1765
1769
1770
+ _ShapeType = TypeVar ("_ShapeType" , bound = _Shape )
1766
1771
_ShapeType_co = TypeVar ("_ShapeType_co" , covariant = True , bound = _Shape )
1767
- _ShapeType2 = TypeVar ("_ShapeType2" , bound = _Shape )
1768
1772
_Shape2DType_co = TypeVar ("_Shape2DType_co" , covariant = True , bound = _Shape2D )
1769
1773
_NumberType = TypeVar ("_NumberType" , bound = number [Any ])
1770
1774
@@ -1881,11 +1885,11 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
1881
1885
1882
1886
def __array_wrap__ (
1883
1887
self ,
1884
- array : ndarray [_ShapeType2 , _DType ],
1888
+ array : ndarray [_ShapeType , _DType ],
1885
1889
context : None | tuple [ufunc , tuple [Any , ...], int ] = ...,
1886
1890
return_scalar : builtins .bool = ...,
1887
1891
/ ,
1888
- ) -> ndarray [_ShapeType2 , _DType ]: ...
1892
+ ) -> ndarray [_ShapeType , _DType ]: ...
1889
1893
1890
1894
@overload
1891
1895
def __getitem__ (self , key : (
@@ -2311,40 +2315,14 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
2311
2315
2312
2316
# Unary ops
2313
2317
@overload
2314
- def __abs__ (self : NDArray [_UnknownType ]) -> NDArray [Any ]: ...
2315
- @overload
2316
- def __abs__ (self : NDArray [np .bool ]) -> NDArray [np .bool ]: ...
2317
- @overload
2318
- def __abs__ (self : NDArray [complexfloating [_NBit1 , _NBit1 ]]) -> NDArray [floating [_NBit1 ]]: ...
2319
- @overload
2320
- def __abs__ (self : NDArray [_NumberType ]) -> NDArray [_NumberType ]: ...
2321
- @overload
2322
- def __abs__ (self : NDArray [timedelta64 ]) -> NDArray [timedelta64 ]: ...
2323
- @overload
2324
- def __abs__ (self : NDArray [object_ ]) -> Any : ...
2325
-
2326
- @overload
2327
- def __invert__ (self : NDArray [_UnknownType ]) -> NDArray [Any ]: ...
2328
- @overload
2329
- def __invert__ (self : NDArray [np .bool ]) -> NDArray [np .bool ]: ...
2330
- @overload
2331
- def __invert__ (self : NDArray [_IntType ]) -> NDArray [_IntType ]: ...
2332
- @overload
2333
- def __invert__ (self : NDArray [object_ ]) -> Any : ...
2334
-
2335
- @overload
2336
- def __pos__ (self : NDArray [_NumberType ]) -> NDArray [_NumberType ]: ...
2337
- @overload
2338
- def __pos__ (self : NDArray [timedelta64 ]) -> NDArray [timedelta64 ]: ...
2339
- @overload
2340
- def __pos__ (self : NDArray [object_ ]) -> Any : ...
2341
-
2342
- @overload
2343
- def __neg__ (self : NDArray [_NumberType ]) -> NDArray [_NumberType ]: ...
2318
+ def __abs__ (self : _RealArrayT , / ) -> _RealArrayT : ...
2344
2319
@overload
2345
- def __neg__ (self : NDArray [ timedelta64 ] ) -> NDArray [ timedelta64 ]: ...
2320
+ def __abs__ (self : ndarray [ _ShapeType , dtype [ complex128 ]], / ) -> ndarray [ _ShapeType , dtype [ float64 ] ]: ...
2346
2321
@overload
2347
- def __neg__ (self : NDArray [object_ ]) -> Any : ...
2322
+ def __abs__ (self : ndarray [_ShapeType , dtype [complexfloating [_NBit1 ]]], / ) -> ndarray [_ShapeType , dtype [floating [_NBit1 ]]]: ...
2323
+ def __invert__ (self : _IntegralArrayT , / ) -> _IntegralArrayT : ... # noqa: PYI019
2324
+ def __neg__ (self : _NumericArrayT , / ) -> _NumericArrayT : ... # noqa: PYI019
2325
+ def __pos__ (self : _NumericArrayT , / ) -> _NumericArrayT : ... # noqa: PYI019
2348
2326
2349
2327
# Binary ops
2350
2328
@overload
0 commit comments