@@ -1375,9 +1375,9 @@ class flatiter(Generic[_NdArraySubClass_co]):
1375
1375
@overload
1376
1376
def __array__ (self : flatiter [ndarray [_FlatShapeType , Any ]], dtype : _DType , / ) -> ndarray [_FlatShapeType , _DType ]: ...
1377
1377
@overload
1378
- def __array__ (self : flatiter [ndarray [Any , _DType ]], dtype : None = ..., / ) -> ndarray [Any , _DType ]: ...
1378
+ def __array__ (self : flatiter [ndarray [_Shape , _DType ]], dtype : None = ..., / ) -> ndarray [_Shape , _DType ]: ...
1379
1379
@overload
1380
- def __array__ (self , dtype : _DType , / ) -> ndarray [Any , _DType ]: ...
1380
+ def __array__ (self , dtype : _DType , / ) -> ndarray [_Shape , _DType ]: ...
1381
1381
1382
1382
_OrderKACF : TypeAlias = L [None , "K" , "A" , "C" , "F" ]
1383
1383
_OrderACF : TypeAlias = L [None , "A" , "C" , "F" ]
@@ -1828,11 +1828,15 @@ _DType = TypeVar("_DType", bound=dtype[Any])
1828
1828
_DType_co = TypeVar ("_DType_co" , covariant = True , bound = dtype [Any ])
1829
1829
_FlexDType = TypeVar ("_FlexDType" , bound = dtype [flexible ])
1830
1830
1831
- _ShapeType_co = TypeVar ("_ShapeType_co" , covariant = True , bound = tuple [int , ...])
1832
- _ShapeType2 = TypeVar ("_ShapeType2" , bound = tuple [int , ...])
1833
- _Shape2DType_co = TypeVar ("_Shape2DType_co" , covariant = True , bound = tuple [int , int ])
1831
+ _Shape1D : TypeAlias = tuple [int ]
1832
+ _Shape2D : TypeAlias = tuple [int , int ]
1833
+
1834
+ _ShapeType_co = TypeVar ("_ShapeType_co" , covariant = True , bound = _Shape )
1835
+ _ShapeType2 = TypeVar ("_ShapeType2" , bound = _Shape )
1836
+ _Shape2DType_co = TypeVar ("_Shape2DType_co" , covariant = True , bound = _Shape2D )
1834
1837
_NumberType = TypeVar ("_NumberType" , bound = number [Any ])
1835
1838
1839
+
1836
1840
if sys .version_info >= (3 , 12 ):
1837
1841
from collections .abc import Buffer as _SupportsBuffer
1838
1842
else :
@@ -1958,7 +1962,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
1958
1962
NDArray [integer [Any ]]
1959
1963
| NDArray [np .bool ]
1960
1964
| tuple [NDArray [integer [Any ]] | NDArray [np .bool ], ...]
1961
- )) -> ndarray [Any , _DType_co ]: ...
1965
+ )) -> ndarray [_Shape , _DType_co ]: ...
1962
1966
@overload
1963
1967
def __getitem__ (self , key : SupportsIndex | tuple [SupportsIndex , ...]) -> Any : ...
1964
1968
@overload
@@ -1969,7 +1973,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
1969
1973
| SupportsIndex
1970
1974
| _ArrayLikeInt_co
1971
1975
| tuple [None | slice | EllipsisType | _ArrayLikeInt_co | SupportsIndex , ...]
1972
- )) -> ndarray [Any , _DType_co ]: ...
1976
+ )) -> ndarray [_Shape , _DType_co ]: ...
1973
1977
@overload
1974
1978
def __getitem__ (self : NDArray [void ], key : str ) -> NDArray [Any ]: ...
1975
1979
@overload
@@ -2015,13 +2019,13 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
2015
2019
def squeeze (
2016
2020
self ,
2017
2021
axis : None | SupportsIndex | tuple [SupportsIndex , ...] = ...,
2018
- ) -> ndarray [Any , _DType_co ]: ...
2022
+ ) -> ndarray [_Shape , _DType_co ]: ...
2019
2023
2020
2024
def swapaxes (
2021
2025
self ,
2022
2026
axis1 : SupportsIndex ,
2023
2027
axis2 : SupportsIndex ,
2024
- ) -> ndarray [Any , _DType_co ]: ...
2028
+ ) -> ndarray [_Shape , _DType_co ]: ...
2025
2029
2026
2030
@overload
2027
2031
def transpose (self , axes : None | _ShapeLike , / ) -> Self : ...
@@ -2041,7 +2045,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
2041
2045
offset : SupportsIndex = ...,
2042
2046
axis1 : SupportsIndex = ...,
2043
2047
axis2 : SupportsIndex = ...,
2044
- ) -> ndarray [Any , _DType_co ]: ...
2048
+ ) -> ndarray [_Shape , _DType_co ]: ...
2045
2049
2046
2050
# 1D + 1D returns a scalar;
2047
2051
# all other with at least 1 non-0D array return an ndarray.
@@ -2137,7 +2141,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
2137
2141
axis : None | SupportsIndex = ...,
2138
2142
out : None = ...,
2139
2143
mode : _ModeKind = ...,
2140
- ) -> ndarray [Any , _DType_co ]: ...
2144
+ ) -> ndarray [_Shape , _DType_co ]: ...
2141
2145
@overload
2142
2146
def take (
2143
2147
self ,
@@ -2151,19 +2155,19 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
2151
2155
self ,
2152
2156
repeats : _ArrayLikeInt_co ,
2153
2157
axis : None | SupportsIndex = ...,
2154
- ) -> ndarray [Any , _DType_co ]: ...
2158
+ ) -> ndarray [_Shape , _DType_co ]: ...
2155
2159
2156
2160
# TODO: use `tuple[int]` as shape type once covariant (#26081)
2157
2161
def flatten (
2158
2162
self ,
2159
2163
order : _OrderKACF = ...,
2160
- ) -> ndarray [Any , _DType_co ]: ...
2164
+ ) -> ndarray [_Shape , _DType_co ]: ...
2161
2165
2162
2166
# TODO: use `tuple[int]` as shape type once covariant (#26081)
2163
2167
def ravel (
2164
2168
self ,
2165
2169
order : _OrderKACF = ...,
2166
- ) -> ndarray [Any , _DType_co ]: ...
2170
+ ) -> ndarray [_Shape , _DType_co ]: ...
2167
2171
2168
2172
@overload
2169
2173
def reshape (
@@ -2173,14 +2177,14 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
2173
2177
* ,
2174
2178
order : _OrderACF = ...,
2175
2179
copy : None | bool = ...,
2176
- ) -> ndarray [Any , _DType_co ]: ...
2180
+ ) -> ndarray [_Shape , _DType_co ]: ...
2177
2181
@overload
2178
2182
def reshape (
2179
2183
self ,
2180
2184
* shape : SupportsIndex ,
2181
2185
order : _OrderACF = ...,
2182
2186
copy : None | bool = ...,
2183
- ) -> ndarray [Any , _DType_co ]: ...
2187
+ ) -> ndarray [_Shape , _DType_co ]: ...
2184
2188
2185
2189
@overload
2186
2190
def astype (
@@ -3061,7 +3065,7 @@ class generic(_ArrayOrScalarCommon):
3061
3065
@overload
3062
3066
def __array__ (self , dtype : None = ..., / ) -> NDArray [Self ]: ...
3063
3067
@overload
3064
- def __array__ (self , dtype : _DType , / ) -> ndarray [Any , _DType ]: ...
3068
+ def __array__ (self , dtype : _DType , / ) -> ndarray [_Shape , _DType ]: ...
3065
3069
def __hash__ (self ) -> int : ...
3066
3070
@property
3067
3071
def base (self ) -> None : ...
@@ -4216,7 +4220,7 @@ class poly1d:
4216
4220
@overload
4217
4221
def __array__ (self , t : None = ..., copy : None | bool = ...) -> NDArray [Any ]: ...
4218
4222
@overload
4219
- def __array__ (self , t : _DType , copy : None | bool = ...) -> ndarray [Any , _DType ]: ...
4223
+ def __array__ (self , t : _DType , copy : None | bool = ...) -> ndarray [_Shape , _DType ]: ...
4220
4224
4221
4225
@overload
4222
4226
def __call__ (self , val : _ScalarLike_co ) -> Any : ...
@@ -4256,15 +4260,14 @@ class poly1d:
4256
4260
) -> poly1d : ...
4257
4261
4258
4262
4259
-
4260
4263
class matrix (ndarray [_Shape2DType_co , _DType_co ]):
4261
4264
__array_priority__ : ClassVar [float ]
4262
4265
def __new__ (
4263
4266
subtype ,
4264
4267
data : ArrayLike ,
4265
4268
dtype : DTypeLike = ...,
4266
4269
copy : builtins .bool = ...,
4267
- ) -> matrix [Any , Any ]: ...
4270
+ ) -> matrix [_Shape2D , Any ]: ...
4268
4271
def __array_finalize__ (self , obj : object ) -> None : ...
4269
4272
4270
4273
@overload
@@ -4289,122 +4292,122 @@ class matrix(ndarray[_Shape2DType_co, _DType_co]):
4289
4292
| tuple [None | slice | EllipsisType | _ArrayLikeInt_co | SupportsIndex , ...]
4290
4293
),
4291
4294
/ ,
4292
- ) -> matrix [Any , _DType_co ]: ...
4295
+ ) -> matrix [_Shape2D , _DType_co ]: ...
4293
4296
@overload
4294
- def __getitem__ (self : NDArray [void ], key : str , / ) -> matrix [Any , dtype [Any ]]: ...
4297
+ def __getitem__ (self : NDArray [void ], key : str , / ) -> matrix [_Shape2D , dtype [Any ]]: ...
4295
4298
@overload
4296
4299
def __getitem__ (self : NDArray [void ], key : list [str ], / ) -> matrix [_Shape2DType_co , dtype [void ]]: ...
4297
4300
4298
- def __mul__ (self , other : ArrayLike , / ) -> matrix [Any , Any ]: ...
4299
- def __rmul__ (self , other : ArrayLike , / ) -> matrix [Any , Any ]: ...
4301
+ def __mul__ (self , other : ArrayLike , / ) -> matrix [_Shape2D , Any ]: ...
4302
+ def __rmul__ (self , other : ArrayLike , / ) -> matrix [_Shape2D , Any ]: ...
4300
4303
def __imul__ (self , other : ArrayLike , / ) -> matrix [_Shape2DType_co , _DType_co ]: ...
4301
- def __pow__ (self , other : ArrayLike , / ) -> matrix [Any , Any ]: ...
4304
+ def __pow__ (self , other : ArrayLike , / ) -> matrix [_Shape2D , Any ]: ...
4302
4305
def __ipow__ (self , other : ArrayLike , / ) -> matrix [_Shape2DType_co , _DType_co ]: ...
4303
4306
4304
4307
@overload
4305
4308
def sum (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ...) -> Any : ...
4306
4309
@overload
4307
- def sum (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [Any , Any ]: ...
4310
+ def sum (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [_Shape2D , Any ]: ...
4308
4311
@overload
4309
4312
def sum (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4310
4313
4311
4314
@overload
4312
4315
def mean (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ...) -> Any : ...
4313
4316
@overload
4314
- def mean (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [Any , Any ]: ...
4317
+ def mean (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [_Shape2D , Any ]: ...
4315
4318
@overload
4316
4319
def mean (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4317
4320
4318
4321
@overload
4319
4322
def std (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> Any : ...
4320
4323
@overload
4321
- def std (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> matrix [Any , Any ]: ...
4324
+ def std (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> matrix [_Shape2D , Any ]: ...
4322
4325
@overload
4323
4326
def std (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ..., ddof : float = ...) -> _NdArraySubClass : ...
4324
4327
4325
4328
@overload
4326
4329
def var (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> Any : ...
4327
4330
@overload
4328
- def var (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> matrix [Any , Any ]: ...
4331
+ def var (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> matrix [_Shape2D , Any ]: ...
4329
4332
@overload
4330
4333
def var (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ..., ddof : float = ...) -> _NdArraySubClass : ...
4331
4334
4332
4335
@overload
4333
4336
def prod (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ...) -> Any : ...
4334
4337
@overload
4335
- def prod (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [Any , Any ]: ...
4338
+ def prod (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [_Shape2D , Any ]: ...
4336
4339
@overload
4337
4340
def prod (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4338
4341
4339
4342
@overload
4340
4343
def any (self , axis : None = ..., out : None = ...) -> np .bool : ...
4341
4344
@overload
4342
- def any (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , dtype [np .bool ]]: ...
4345
+ def any (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , dtype [np .bool ]]: ...
4343
4346
@overload
4344
4347
def any (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4345
4348
4346
4349
@overload
4347
4350
def all (self , axis : None = ..., out : None = ...) -> np .bool : ...
4348
4351
@overload
4349
- def all (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , dtype [np .bool ]]: ...
4352
+ def all (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , dtype [np .bool ]]: ...
4350
4353
@overload
4351
4354
def all (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4352
4355
4353
4356
@overload
4354
4357
def max (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> _ScalarType : ...
4355
4358
@overload
4356
- def max (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , _DType_co ]: ...
4359
+ def max (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , _DType_co ]: ...
4357
4360
@overload
4358
4361
def max (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4359
4362
4360
4363
@overload
4361
4364
def min (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> _ScalarType : ...
4362
4365
@overload
4363
- def min (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , _DType_co ]: ...
4366
+ def min (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , _DType_co ]: ...
4364
4367
@overload
4365
4368
def min (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4366
4369
4367
4370
@overload
4368
4371
def argmax (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> intp : ...
4369
4372
@overload
4370
- def argmax (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , dtype [intp ]]: ...
4373
+ def argmax (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , dtype [intp ]]: ...
4371
4374
@overload
4372
4375
def argmax (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4373
4376
4374
4377
@overload
4375
4378
def argmin (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> intp : ...
4376
4379
@overload
4377
- def argmin (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , dtype [intp ]]: ...
4380
+ def argmin (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , dtype [intp ]]: ...
4378
4381
@overload
4379
4382
def argmin (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4380
4383
4381
4384
@overload
4382
4385
def ptp (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> _ScalarType : ...
4383
4386
@overload
4384
- def ptp (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , _DType_co ]: ...
4387
+ def ptp (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , _DType_co ]: ...
4385
4388
@overload
4386
4389
def ptp (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4387
4390
4388
- def squeeze (self , axis : None | _ShapeLike = ...) -> matrix [Any , _DType_co ]: ...
4389
- def tolist (self : matrix [Any , dtype [_SupportsItem [_T ]]]) -> list [list [_T ]]: ... # type: ignore[typevar]
4390
- def ravel (self , order : _OrderKACF = ...) -> matrix [Any , _DType_co ]: ...
4391
- def flatten (self , order : _OrderKACF = ...) -> matrix [Any , _DType_co ]: ...
4391
+ def squeeze (self , axis : None | _ShapeLike = ...) -> matrix [_Shape2D , _DType_co ]: ...
4392
+ def tolist (self : matrix [_Shape2D , dtype [_SupportsItem [_T ]]]) -> list [list [_T ]]: ... # type: ignore[typevar]
4393
+ def ravel (self , order : _OrderKACF = ...) -> matrix [_Shape2D , _DType_co ]: ...
4394
+ def flatten (self , order : _OrderKACF = ...) -> matrix [_Shape2D , _DType_co ]: ...
4392
4395
4393
4396
@property
4394
- def T (self ) -> matrix [Any , _DType_co ]: ...
4397
+ def T (self ) -> matrix [_Shape2D , _DType_co ]: ...
4395
4398
@property
4396
- def I (self ) -> matrix [Any , Any ]: ...
4399
+ def I (self ) -> matrix [_Shape2D , Any ]: ...
4397
4400
@property
4398
4401
def A (self ) -> ndarray [_Shape2DType_co , _DType_co ]: ...
4399
4402
@property
4400
- def A1 (self ) -> ndarray [Any , _DType_co ]: ...
4403
+ def A1 (self ) -> ndarray [_Shape , _DType_co ]: ...
4401
4404
@property
4402
- def H (self ) -> matrix [Any , _DType_co ]: ...
4403
- def getT (self ) -> matrix [Any , _DType_co ]: ...
4404
- def getI (self ) -> matrix [Any , Any ]: ...
4405
+ def H (self ) -> matrix [_Shape2D , _DType_co ]: ...
4406
+ def getT (self ) -> matrix [_Shape2D , _DType_co ]: ...
4407
+ def getI (self ) -> matrix [_Shape2D , Any ]: ...
4405
4408
def getA (self ) -> ndarray [_Shape2DType_co , _DType_co ]: ...
4406
- def getA1 (self ) -> ndarray [Any , _DType_co ]: ...
4407
- def getH (self ) -> matrix [Any , _DType_co ]: ...
4409
+ def getA1 (self ) -> ndarray [_Shape , _DType_co ]: ...
4410
+ def getH (self ) -> matrix [_Shape2D , _DType_co ]: ...
4408
4411
4409
4412
_CharType = TypeVar ("_CharType" , str_ , bytes_ )
4410
4413
_CharDType = TypeVar ("_CharDType" , dtype [str_ ], dtype [bytes_ ])
0 commit comments