@@ -1376,9 +1376,9 @@ class flatiter(Generic[_NdArraySubClass_co]):
1376
1376
@overload
1377
1377
def __array__ (self : flatiter [ndarray [_FlatShapeType , Any ]], dtype : _DType , / ) -> ndarray [_FlatShapeType , _DType ]: ...
1378
1378
@overload
1379
- def __array__ (self : flatiter [ndarray [Any , _DType ]], dtype : None = ..., / ) -> ndarray [Any , _DType ]: ...
1379
+ def __array__ (self : flatiter [ndarray [_Shape , _DType ]], dtype : None = ..., / ) -> ndarray [_Shape , _DType ]: ...
1380
1380
@overload
1381
- def __array__ (self , dtype : _DType , / ) -> ndarray [Any , _DType ]: ...
1381
+ def __array__ (self , dtype : _DType , / ) -> ndarray [_Shape , _DType ]: ...
1382
1382
1383
1383
_OrderKACF : TypeAlias = L [None , "K" , "A" , "C" , "F" ]
1384
1384
_OrderACF : TypeAlias = L [None , "A" , "C" , "F" ]
@@ -1831,11 +1831,15 @@ _DType = TypeVar("_DType", bound=dtype[Any])
1831
1831
_DType_co = TypeVar ("_DType_co" , covariant = True , bound = dtype [Any ])
1832
1832
_FlexDType = TypeVar ("_FlexDType" , bound = dtype [flexible ])
1833
1833
1834
- _ShapeType_co = TypeVar ("_ShapeType_co" , covariant = True , bound = tuple [int , ...])
1835
- _ShapeType2 = TypeVar ("_ShapeType2" , bound = tuple [int , ...])
1836
- _Shape2DType_co = TypeVar ("_Shape2DType_co" , covariant = True , bound = tuple [int , int ])
1834
+ _Shape1D : TypeAlias = tuple [int ]
1835
+ _Shape2D : TypeAlias = tuple [int , int ]
1836
+
1837
+ _ShapeType_co = TypeVar ("_ShapeType_co" , covariant = True , bound = _Shape )
1838
+ _ShapeType2 = TypeVar ("_ShapeType2" , bound = _Shape )
1839
+ _Shape2DType_co = TypeVar ("_Shape2DType_co" , covariant = True , bound = _Shape2D )
1837
1840
_NumberType = TypeVar ("_NumberType" , bound = number [Any ])
1838
1841
1842
+
1839
1843
if sys .version_info >= (3 , 12 ):
1840
1844
from collections .abc import Buffer as _SupportsBuffer
1841
1845
else :
@@ -1961,7 +1965,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
1961
1965
NDArray [integer [Any ]]
1962
1966
| NDArray [np .bool ]
1963
1967
| tuple [NDArray [integer [Any ]] | NDArray [np .bool ], ...]
1964
- )) -> ndarray [Any , _DType_co ]: ...
1968
+ )) -> ndarray [_Shape , _DType_co ]: ...
1965
1969
@overload
1966
1970
def __getitem__ (self , key : SupportsIndex | tuple [SupportsIndex , ...]) -> Any : ...
1967
1971
@overload
@@ -1972,7 +1976,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
1972
1976
| SupportsIndex
1973
1977
| _ArrayLikeInt_co
1974
1978
| tuple [None | slice | EllipsisType | _ArrayLikeInt_co | SupportsIndex , ...]
1975
- )) -> ndarray [Any , _DType_co ]: ...
1979
+ )) -> ndarray [_Shape , _DType_co ]: ...
1976
1980
@overload
1977
1981
def __getitem__ (self : NDArray [void ], key : str ) -> NDArray [Any ]: ...
1978
1982
@overload
@@ -2018,13 +2022,13 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
2018
2022
def squeeze (
2019
2023
self ,
2020
2024
axis : None | SupportsIndex | tuple [SupportsIndex , ...] = ...,
2021
- ) -> ndarray [Any , _DType_co ]: ...
2025
+ ) -> ndarray [_Shape , _DType_co ]: ...
2022
2026
2023
2027
def swapaxes (
2024
2028
self ,
2025
2029
axis1 : SupportsIndex ,
2026
2030
axis2 : SupportsIndex ,
2027
- ) -> ndarray [Any , _DType_co ]: ...
2031
+ ) -> ndarray [_Shape , _DType_co ]: ...
2028
2032
2029
2033
@overload
2030
2034
def transpose (self : _ArraySelf , axes : None | _ShapeLike , / ) -> _ArraySelf : ...
@@ -2044,7 +2048,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
2044
2048
offset : SupportsIndex = ...,
2045
2049
axis1 : SupportsIndex = ...,
2046
2050
axis2 : SupportsIndex = ...,
2047
- ) -> ndarray [Any , _DType_co ]: ...
2051
+ ) -> ndarray [_Shape , _DType_co ]: ...
2048
2052
2049
2053
# 1D + 1D returns a scalar;
2050
2054
# all other with at least 1 non-0D array return an ndarray.
@@ -2140,7 +2144,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
2140
2144
axis : None | SupportsIndex = ...,
2141
2145
out : None = ...,
2142
2146
mode : _ModeKind = ...,
2143
- ) -> ndarray [Any , _DType_co ]: ...
2147
+ ) -> ndarray [_Shape , _DType_co ]: ...
2144
2148
@overload
2145
2149
def take (
2146
2150
self ,
@@ -2154,19 +2158,19 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
2154
2158
self ,
2155
2159
repeats : _ArrayLikeInt_co ,
2156
2160
axis : None | SupportsIndex = ...,
2157
- ) -> ndarray [Any , _DType_co ]: ...
2161
+ ) -> ndarray [_Shape , _DType_co ]: ...
2158
2162
2159
2163
# TODO: use `tuple[int]` as shape type once covariant (#26081)
2160
2164
def flatten (
2161
2165
self ,
2162
2166
order : _OrderKACF = ...,
2163
- ) -> ndarray [Any , _DType_co ]: ...
2167
+ ) -> ndarray [_Shape , _DType_co ]: ...
2164
2168
2165
2169
# TODO: use `tuple[int]` as shape type once covariant (#26081)
2166
2170
def ravel (
2167
2171
self ,
2168
2172
order : _OrderKACF = ...,
2169
- ) -> ndarray [Any , _DType_co ]: ...
2173
+ ) -> ndarray [_Shape , _DType_co ]: ...
2170
2174
2171
2175
@overload
2172
2176
def reshape (
@@ -2176,14 +2180,14 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
2176
2180
* ,
2177
2181
order : _OrderACF = ...,
2178
2182
copy : None | bool = ...,
2179
- ) -> ndarray [Any , _DType_co ]: ...
2183
+ ) -> ndarray [_Shape , _DType_co ]: ...
2180
2184
@overload
2181
2185
def reshape (
2182
2186
self ,
2183
2187
* shape : SupportsIndex ,
2184
2188
order : _OrderACF = ...,
2185
2189
copy : None | bool = ...,
2186
- ) -> ndarray [Any , _DType_co ]: ...
2190
+ ) -> ndarray [_Shape , _DType_co ]: ...
2187
2191
2188
2192
@overload
2189
2193
def astype (
@@ -3069,7 +3073,7 @@ class generic(_ArrayOrScalarCommon):
3069
3073
@overload
3070
3074
def __array__ (self : _ScalarType , dtype : None = ..., / ) -> NDArray [_ScalarType ]: ...
3071
3075
@overload
3072
- def __array__ (self , dtype : _DType , / ) -> ndarray [Any , _DType ]: ...
3076
+ def __array__ (self , dtype : _DType , / ) -> ndarray [_Shape , _DType ]: ...
3073
3077
def __hash__ (self ) -> int : ...
3074
3078
@property
3075
3079
def base (self ) -> None : ...
@@ -4247,7 +4251,7 @@ class poly1d:
4247
4251
@overload
4248
4252
def __array__ (self , t : None = ..., copy : None | bool = ...) -> NDArray [Any ]: ...
4249
4253
@overload
4250
- def __array__ (self , t : _DType , copy : None | bool = ...) -> ndarray [Any , _DType ]: ...
4254
+ def __array__ (self , t : _DType , copy : None | bool = ...) -> ndarray [_Shape , _DType ]: ...
4251
4255
4252
4256
@overload
4253
4257
def __call__ (self , val : _ScalarLike_co ) -> Any : ...
@@ -4287,15 +4291,14 @@ class poly1d:
4287
4291
) -> poly1d : ...
4288
4292
4289
4293
4290
-
4291
4294
class matrix (ndarray [_Shape2DType_co , _DType_co ]):
4292
4295
__array_priority__ : ClassVar [float ]
4293
4296
def __new__ (
4294
4297
subtype ,
4295
4298
data : ArrayLike ,
4296
4299
dtype : DTypeLike = ...,
4297
4300
copy : builtins .bool = ...,
4298
- ) -> matrix [Any , Any ]: ...
4301
+ ) -> matrix [_Shape2D , Any ]: ...
4299
4302
def __array_finalize__ (self , obj : object ) -> None : ...
4300
4303
4301
4304
@overload
@@ -4320,122 +4323,122 @@ class matrix(ndarray[_Shape2DType_co, _DType_co]):
4320
4323
| tuple [None | slice | EllipsisType | _ArrayLikeInt_co | SupportsIndex , ...]
4321
4324
),
4322
4325
/ ,
4323
- ) -> matrix [Any , _DType_co ]: ...
4326
+ ) -> matrix [_Shape2D , _DType_co ]: ...
4324
4327
@overload
4325
- def __getitem__ (self : NDArray [void ], key : str , / ) -> matrix [Any , dtype [Any ]]: ...
4328
+ def __getitem__ (self : NDArray [void ], key : str , / ) -> matrix [_Shape2D , dtype [Any ]]: ...
4326
4329
@overload
4327
4330
def __getitem__ (self : NDArray [void ], key : list [str ], / ) -> matrix [_Shape2DType_co , dtype [void ]]: ...
4328
4331
4329
- def __mul__ (self , other : ArrayLike , / ) -> matrix [Any , Any ]: ...
4330
- def __rmul__ (self , other : ArrayLike , / ) -> matrix [Any , Any ]: ...
4332
+ def __mul__ (self , other : ArrayLike , / ) -> matrix [_Shape2D , Any ]: ...
4333
+ def __rmul__ (self , other : ArrayLike , / ) -> matrix [_Shape2D , Any ]: ...
4331
4334
def __imul__ (self , other : ArrayLike , / ) -> matrix [_Shape2DType_co , _DType_co ]: ...
4332
- def __pow__ (self , other : ArrayLike , / ) -> matrix [Any , Any ]: ...
4335
+ def __pow__ (self , other : ArrayLike , / ) -> matrix [_Shape2D , Any ]: ...
4333
4336
def __ipow__ (self , other : ArrayLike , / ) -> matrix [_Shape2DType_co , _DType_co ]: ...
4334
4337
4335
4338
@overload
4336
4339
def sum (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ...) -> Any : ...
4337
4340
@overload
4338
- def sum (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [Any , Any ]: ...
4341
+ def sum (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [_Shape2D , Any ]: ...
4339
4342
@overload
4340
4343
def sum (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4341
4344
4342
4345
@overload
4343
4346
def mean (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ...) -> Any : ...
4344
4347
@overload
4345
- def mean (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [Any , Any ]: ...
4348
+ def mean (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [_Shape2D , Any ]: ...
4346
4349
@overload
4347
4350
def mean (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4348
4351
4349
4352
@overload
4350
4353
def std (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> Any : ...
4351
4354
@overload
4352
- def std (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> matrix [Any , Any ]: ...
4355
+ def std (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> matrix [_Shape2D , Any ]: ...
4353
4356
@overload
4354
4357
def std (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ..., ddof : float = ...) -> _NdArraySubClass : ...
4355
4358
4356
4359
@overload
4357
4360
def var (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> Any : ...
4358
4361
@overload
4359
- def var (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> matrix [Any , Any ]: ...
4362
+ def var (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> matrix [_Shape2D , Any ]: ...
4360
4363
@overload
4361
4364
def var (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ..., ddof : float = ...) -> _NdArraySubClass : ...
4362
4365
4363
4366
@overload
4364
4367
def prod (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ...) -> Any : ...
4365
4368
@overload
4366
- def prod (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [Any , Any ]: ...
4369
+ def prod (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [_Shape2D , Any ]: ...
4367
4370
@overload
4368
4371
def prod (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4369
4372
4370
4373
@overload
4371
4374
def any (self , axis : None = ..., out : None = ...) -> np .bool : ...
4372
4375
@overload
4373
- def any (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , dtype [np .bool ]]: ...
4376
+ def any (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , dtype [np .bool ]]: ...
4374
4377
@overload
4375
4378
def any (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4376
4379
4377
4380
@overload
4378
4381
def all (self , axis : None = ..., out : None = ...) -> np .bool : ...
4379
4382
@overload
4380
- def all (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , dtype [np .bool ]]: ...
4383
+ def all (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , dtype [np .bool ]]: ...
4381
4384
@overload
4382
4385
def all (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4383
4386
4384
4387
@overload
4385
4388
def max (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> _ScalarType : ...
4386
4389
@overload
4387
- def max (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , _DType_co ]: ...
4390
+ def max (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , _DType_co ]: ...
4388
4391
@overload
4389
4392
def max (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4390
4393
4391
4394
@overload
4392
4395
def min (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> _ScalarType : ...
4393
4396
@overload
4394
- def min (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , _DType_co ]: ...
4397
+ def min (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , _DType_co ]: ...
4395
4398
@overload
4396
4399
def min (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4397
4400
4398
4401
@overload
4399
4402
def argmax (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> intp : ...
4400
4403
@overload
4401
- def argmax (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , dtype [intp ]]: ...
4404
+ def argmax (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , dtype [intp ]]: ...
4402
4405
@overload
4403
4406
def argmax (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4404
4407
4405
4408
@overload
4406
4409
def argmin (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> intp : ...
4407
4410
@overload
4408
- def argmin (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , dtype [intp ]]: ...
4411
+ def argmin (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , dtype [intp ]]: ...
4409
4412
@overload
4410
4413
def argmin (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4411
4414
4412
4415
@overload
4413
4416
def ptp (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> _ScalarType : ...
4414
4417
@overload
4415
- def ptp (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , _DType_co ]: ...
4418
+ def ptp (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , _DType_co ]: ...
4416
4419
@overload
4417
4420
def ptp (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4418
4421
4419
- def squeeze (self , axis : None | _ShapeLike = ...) -> matrix [Any , _DType_co ]: ...
4420
- def tolist (self : matrix [Any , dtype [_SupportsItem [_T ]]]) -> list [list [_T ]]: ... # type: ignore[typevar]
4421
- def ravel (self , order : _OrderKACF = ...) -> matrix [Any , _DType_co ]: ...
4422
- def flatten (self , order : _OrderKACF = ...) -> matrix [Any , _DType_co ]: ...
4422
+ def squeeze (self , axis : None | _ShapeLike = ...) -> matrix [_Shape2D , _DType_co ]: ...
4423
+ def tolist (self : matrix [_Shape2D , dtype [_SupportsItem [_T ]]]) -> list [list [_T ]]: ... # type: ignore[typevar]
4424
+ def ravel (self , order : _OrderKACF = ...) -> matrix [_Shape2D , _DType_co ]: ...
4425
+ def flatten (self , order : _OrderKACF = ...) -> matrix [_Shape2D , _DType_co ]: ...
4423
4426
4424
4427
@property
4425
- def T (self ) -> matrix [Any , _DType_co ]: ...
4428
+ def T (self ) -> matrix [_Shape2D , _DType_co ]: ...
4426
4429
@property
4427
- def I (self ) -> matrix [Any , Any ]: ...
4430
+ def I (self ) -> matrix [_Shape2D , Any ]: ...
4428
4431
@property
4429
4432
def A (self ) -> ndarray [_Shape2DType_co , _DType_co ]: ...
4430
4433
@property
4431
- def A1 (self ) -> ndarray [Any , _DType_co ]: ...
4434
+ def A1 (self ) -> ndarray [_Shape , _DType_co ]: ...
4432
4435
@property
4433
- def H (self ) -> matrix [Any , _DType_co ]: ...
4434
- def getT (self ) -> matrix [Any , _DType_co ]: ...
4435
- def getI (self ) -> matrix [Any , Any ]: ...
4436
+ def H (self ) -> matrix [_Shape2D , _DType_co ]: ...
4437
+ def getT (self ) -> matrix [_Shape2D , _DType_co ]: ...
4438
+ def getI (self ) -> matrix [_Shape2D , Any ]: ...
4436
4439
def getA (self ) -> ndarray [_Shape2DType_co , _DType_co ]: ...
4437
- def getA1 (self ) -> ndarray [Any , _DType_co ]: ...
4438
- def getH (self ) -> matrix [Any , _DType_co ]: ...
4440
+ def getA1 (self ) -> ndarray [_Shape , _DType_co ]: ...
4441
+ def getH (self ) -> matrix [_Shape2D , _DType_co ]: ...
4439
4442
4440
4443
_CharType = TypeVar ("_CharType" , str_ , bytes_ )
4441
4444
_CharDType = TypeVar ("_CharDType" , dtype [str_ ], dtype [bytes_ ])
0 commit comments