@@ -1044,9 +1044,9 @@ class flatiter(Generic[_NdArraySubClass_co]):
1044
1044
@overload
1045
1045
def __array__ (self : flatiter [ndarray [_FlatShapeType , Any ]], dtype : _DType , / ) -> ndarray [_FlatShapeType , _DType ]: ...
1046
1046
@overload
1047
- def __array__ (self : flatiter [ndarray [Any , _DType ]], dtype : None = ..., / ) -> ndarray [Any , _DType ]: ...
1047
+ def __array__ (self : flatiter [ndarray [_Shape , _DType ]], dtype : None = ..., / ) -> ndarray [_Shape , _DType ]: ...
1048
1048
@overload
1049
- def __array__ (self , dtype : _DType , / ) -> ndarray [Any , _DType ]: ...
1049
+ def __array__ (self , dtype : _DType , / ) -> ndarray [_Shape , _DType ]: ...
1050
1050
1051
1051
_OrderKACF : TypeAlias = L [None , "K" , "A" , "C" , "F" ]
1052
1052
_OrderACF : TypeAlias = L [None , "A" , "C" , "F" ]
@@ -1499,11 +1499,15 @@ _DType = TypeVar("_DType", bound=dtype[Any])
1499
1499
_DType_co = TypeVar ("_DType_co" , covariant = True , bound = dtype [Any ])
1500
1500
_FlexDType = TypeVar ("_FlexDType" , bound = dtype [flexible ])
1501
1501
1502
- _ShapeType_co = TypeVar ("_ShapeType_co", covariant = True , bound = tuple [int , ...])
1503
- _ShapeType2 = TypeVar ("_ShapeType2" , bound = tuple [int , ...])
1504
- _Shape2DType_co = TypeVar ("_Shape2DType_co" , covariant = True , bound = tuple [int , int ])
1502
+ _Shape1D : TypeAlias = tuple [int ]
1503
+ _Shape2D : TypeAlias = tuple [int , int ]
1504
+
1505
+ _ShapeType_co = TypeVar ("_ShapeType_co" , covariant = True , bound = _Shape )
1506
+ _ShapeType2 = TypeVar ("_ShapeType2" , bound = _Shape )
1507
+ _Shape2DType_co = TypeVar ("_Shape2DType_co" , covariant = True , bound = _Shape2D )
1505
1508
_NumberType = TypeVar ("_NumberType" , bound = number [Any ])
1506
1509
1510
+
1507
1511
if sys .version_info >= (3 , 12 ):
1508
1512
from collections .abc import Buffer as _SupportsBuffer
1509
1513
else :
@@ -1629,7 +1633,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
1629
1633
NDArray [integer [Any ]]
1630
1634
| NDArray [np .bool ]
1631
1635
| tuple [NDArray [integer [Any ]] | NDArray [np .bool ], ...]
1632
- )) -> ndarray [Any , _DType_co ]: ...
1636
+ )) -> ndarray [_Shape , _DType_co ]: ...
1633
1637
@overload
1634
1638
def __getitem__ (self , key : SupportsIndex | tuple [SupportsIndex , ...]) -> Any : ...
1635
1639
@overload
@@ -1640,7 +1644,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
1640
1644
| SupportsIndex
1641
1645
| _ArrayLikeInt_co
1642
1646
| tuple [None | slice | EllipsisType | _ArrayLikeInt_co | SupportsIndex , ...]
1643
- )) -> ndarray [Any , _DType_co ]: ...
1647
+ )) -> ndarray [_Shape , _DType_co ]: ...
1644
1648
@overload
1645
1649
def __getitem__ (self : NDArray [void ], key : str ) -> NDArray [Any ]: ...
1646
1650
@overload
@@ -1686,13 +1690,13 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
1686
1690
def squeeze (
1687
1691
self ,
1688
1692
axis : None | SupportsIndex | tuple [SupportsIndex , ...] = ...,
1689
- ) -> ndarray [Any , _DType_co ]: ...
1693
+ ) -> ndarray [_Shape , _DType_co ]: ...
1690
1694
1691
1695
def swapaxes (
1692
1696
self ,
1693
1697
axis1 : SupportsIndex ,
1694
1698
axis2 : SupportsIndex ,
1695
- ) -> ndarray [Any , _DType_co ]: ...
1699
+ ) -> ndarray [_Shape , _DType_co ]: ...
1696
1700
1697
1701
@overload
1698
1702
def transpose (self : _ArraySelf , axes : None | _ShapeLike , / ) -> _ArraySelf : ...
@@ -1712,7 +1716,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
1712
1716
offset : SupportsIndex = ...,
1713
1717
axis1 : SupportsIndex = ...,
1714
1718
axis2 : SupportsIndex = ...,
1715
- ) -> ndarray [Any , _DType_co ]: ...
1719
+ ) -> ndarray [_Shape , _DType_co ]: ...
1716
1720
1717
1721
# 1D + 1D returns a scalar;
1718
1722
# all other with at least 1 non-0D array return an ndarray.
@@ -1808,7 +1812,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
1808
1812
axis : None | SupportsIndex = ...,
1809
1813
out : None = ...,
1810
1814
mode : _ModeKind = ...,
1811
- ) -> ndarray [Any , _DType_co ]: ...
1815
+ ) -> ndarray [_Shape , _DType_co ]: ...
1812
1816
@overload
1813
1817
def take (
1814
1818
self ,
@@ -1822,19 +1826,19 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
1822
1826
self ,
1823
1827
repeats : _ArrayLikeInt_co ,
1824
1828
axis : None | SupportsIndex = ...,
1825
- ) -> ndarray [Any , _DType_co ]: ...
1829
+ ) -> ndarray [_Shape , _DType_co ]: ...
1826
1830
1827
1831
# TODO: use `tuple[int]` as shape type once covariant (#26081)
1828
1832
def flatten (
1829
1833
self ,
1830
1834
order : _OrderKACF = ...,
1831
- ) -> ndarray [Any , _DType_co ]: ...
1835
+ ) -> ndarray [_Shape , _DType_co ]: ...
1832
1836
1833
1837
# TODO: use `tuple[int]` as shape type once covariant (#26081)
1834
1838
def ravel (
1835
1839
self ,
1836
1840
order : _OrderKACF = ...,
1837
- ) -> ndarray [Any , _DType_co ]: ...
1841
+ ) -> ndarray [_Shape , _DType_co ]: ...
1838
1842
1839
1843
@overload
1840
1844
def reshape (
@@ -1844,14 +1848,14 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
1844
1848
* ,
1845
1849
order : _OrderACF = ...,
1846
1850
copy : None | bool = ...,
1847
- ) -> ndarray [Any , _DType_co ]: ...
1851
+ ) -> ndarray [_Shape , _DType_co ]: ...
1848
1852
@overload
1849
1853
def reshape (
1850
1854
self ,
1851
1855
* shape : SupportsIndex ,
1852
1856
order : _OrderACF = ...,
1853
1857
copy : None | bool = ...,
1854
- ) -> ndarray [Any , _DType_co ]: ...
1858
+ ) -> ndarray [_Shape , _DType_co ]: ...
1855
1859
1856
1860
@overload
1857
1861
def astype (
@@ -2737,7 +2741,7 @@ class generic(_ArrayOrScalarCommon):
2737
2741
@overload
2738
2742
def __array__ (self : _ScalarType , dtype : None = ..., / ) -> NDArray [_ScalarType ]: ...
2739
2743
@overload
2740
- def __array__ (self , dtype : _DType , / ) -> ndarray [Any , _DType ]: ...
2744
+ def __array__ (self , dtype : _DType , / ) -> ndarray [_Shape , _DType ]: ...
2741
2745
def __hash__ (self ) -> int : ...
2742
2746
@property
2743
2747
def base (self ) -> None : ...
@@ -3886,7 +3890,7 @@ class poly1d:
3886
3890
@overload
3887
3891
def __array__ (self , t : None = ..., copy : None | bool = ...) -> NDArray [Any ]: ...
3888
3892
@overload
3889
- def __array__ (self , t : _DType , copy : None | bool = ...) -> ndarray [Any , _DType ]: ...
3893
+ def __array__ (self , t : _DType , copy : None | bool = ...) -> ndarray [_Shape , _DType ]: ...
3890
3894
3891
3895
@overload
3892
3896
def __call__ (self , val : _ScalarLike_co ) -> Any : ...
@@ -3926,15 +3930,14 @@ class poly1d:
3926
3930
) -> poly1d : ...
3927
3931
3928
3932
3929
-
3930
3933
class matrix (ndarray [_Shape2DType_co , _DType_co ]):
3931
3934
__array_priority__ : ClassVar [float ]
3932
3935
def __new__ (
3933
3936
subtype ,
3934
3937
data : ArrayLike ,
3935
3938
dtype : DTypeLike = ...,
3936
3939
copy : builtins .bool = ...,
3937
- ) -> matrix [Any , Any ]: ...
3940
+ ) -> matrix [_Shape2D , Any ]: ...
3938
3941
def __array_finalize__ (self , obj : object ) -> None : ...
3939
3942
3940
3943
@overload
@@ -3959,122 +3962,122 @@ class matrix(ndarray[_Shape2DType_co, _DType_co]):
3959
3962
| tuple [None | slice | EllipsisType | _ArrayLikeInt_co | SupportsIndex , ...]
3960
3963
),
3961
3964
/ ,
3962
- ) -> matrix [Any , _DType_co ]: ...
3965
+ ) -> matrix [_Shape2D , _DType_co ]: ...
3963
3966
@overload
3964
- def __getitem__ (self : NDArray [void ], key : str , / ) -> matrix [Any , dtype [Any ]]: ...
3967
+ def __getitem__ (self : NDArray [void ], key : str , / ) -> matrix [_Shape2D , dtype [Any ]]: ...
3965
3968
@overload
3966
3969
def __getitem__ (self : NDArray [void ], key : list [str ], / ) -> matrix [_Shape2DType_co , dtype [void ]]: ...
3967
3970
3968
- def __mul__ (self , other : ArrayLike , / ) -> matrix [Any , Any ]: ...
3969
- def __rmul__ (self , other : ArrayLike , / ) -> matrix [Any , Any ]: ...
3971
+ def __mul__ (self , other : ArrayLike , / ) -> matrix [_Shape2D , Any ]: ...
3972
+ def __rmul__ (self , other : ArrayLike , / ) -> matrix [_Shape2D , Any ]: ...
3970
3973
def __imul__ (self , other : ArrayLike , / ) -> matrix [_Shape2DType_co , _DType_co ]: ...
3971
- def __pow__ (self , other : ArrayLike , / ) -> matrix [Any , Any ]: ...
3974
+ def __pow__ (self , other : ArrayLike , / ) -> matrix [_Shape2D , Any ]: ...
3972
3975
def __ipow__ (self , other : ArrayLike , / ) -> matrix [_Shape2DType_co , _DType_co ]: ...
3973
3976
3974
3977
@overload
3975
3978
def sum (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ...) -> Any : ...
3976
3979
@overload
3977
- def sum (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [Any , Any ]: ...
3980
+ def sum (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [_Shape2D , Any ]: ...
3978
3981
@overload
3979
3982
def sum (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
3980
3983
3981
3984
@overload
3982
3985
def mean (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ...) -> Any : ...
3983
3986
@overload
3984
- def mean (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [Any , Any ]: ...
3987
+ def mean (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [_Shape2D , Any ]: ...
3985
3988
@overload
3986
3989
def mean (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
3987
3990
3988
3991
@overload
3989
3992
def std (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> Any : ...
3990
3993
@overload
3991
- def std (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> matrix [Any , Any ]: ...
3994
+ def std (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> matrix [_Shape2D , Any ]: ...
3992
3995
@overload
3993
3996
def std (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ..., ddof : float = ...) -> _NdArraySubClass : ...
3994
3997
3995
3998
@overload
3996
3999
def var (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> Any : ...
3997
4000
@overload
3998
- def var (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> matrix [Any , Any ]: ...
4001
+ def var (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ..., ddof : float = ...) -> matrix [_Shape2D , Any ]: ...
3999
4002
@overload
4000
4003
def var (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ..., ddof : float = ...) -> _NdArraySubClass : ...
4001
4004
4002
4005
@overload
4003
4006
def prod (self , axis : None = ..., dtype : DTypeLike = ..., out : None = ...) -> Any : ...
4004
4007
@overload
4005
- def prod (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [Any , Any ]: ...
4008
+ def prod (self , axis : _ShapeLike , dtype : DTypeLike = ..., out : None = ...) -> matrix [_Shape2D , Any ]: ...
4006
4009
@overload
4007
4010
def prod (self , axis : None | _ShapeLike = ..., dtype : DTypeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4008
4011
4009
4012
@overload
4010
4013
def any (self , axis : None = ..., out : None = ...) -> np .bool : ...
4011
4014
@overload
4012
- def any (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , dtype [np .bool ]]: ...
4015
+ def any (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , dtype [np .bool ]]: ...
4013
4016
@overload
4014
4017
def any (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4015
4018
4016
4019
@overload
4017
4020
def all (self , axis : None = ..., out : None = ...) -> np .bool : ...
4018
4021
@overload
4019
- def all (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , dtype [np .bool ]]: ...
4022
+ def all (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , dtype [np .bool ]]: ...
4020
4023
@overload
4021
4024
def all (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4022
4025
4023
4026
@overload
4024
4027
def max (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> _ScalarType : ...
4025
4028
@overload
4026
- def max (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , _DType_co ]: ...
4029
+ def max (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , _DType_co ]: ...
4027
4030
@overload
4028
4031
def max (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4029
4032
4030
4033
@overload
4031
4034
def min (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> _ScalarType : ...
4032
4035
@overload
4033
- def min (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , _DType_co ]: ...
4036
+ def min (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , _DType_co ]: ...
4034
4037
@overload
4035
4038
def min (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4036
4039
4037
4040
@overload
4038
4041
def argmax (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> intp : ...
4039
4042
@overload
4040
- def argmax (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , dtype [intp ]]: ...
4043
+ def argmax (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , dtype [intp ]]: ...
4041
4044
@overload
4042
4045
def argmax (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4043
4046
4044
4047
@overload
4045
4048
def argmin (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> intp : ...
4046
4049
@overload
4047
- def argmin (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , dtype [intp ]]: ...
4050
+ def argmin (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , dtype [intp ]]: ...
4048
4051
@overload
4049
4052
def argmin (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4050
4053
4051
4054
@overload
4052
4055
def ptp (self : NDArray [_ScalarType ], axis : None = ..., out : None = ...) -> _ScalarType : ...
4053
4056
@overload
4054
- def ptp (self , axis : _ShapeLike , out : None = ...) -> matrix [Any , _DType_co ]: ...
4057
+ def ptp (self , axis : _ShapeLike , out : None = ...) -> matrix [_Shape2D , _DType_co ]: ...
4055
4058
@overload
4056
4059
def ptp (self , axis : None | _ShapeLike = ..., out : _NdArraySubClass = ...) -> _NdArraySubClass : ...
4057
4060
4058
- def squeeze (self , axis : None | _ShapeLike = ...) -> matrix [Any , _DType_co ]: ...
4059
- def tolist (self : matrix [Any , dtype [_SupportsItem [_T ]]]) -> list [list [_T ]]: ... # type: ignore[typevar]
4060
- def ravel (self , order : _OrderKACF = ...) -> matrix [Any , _DType_co ]: ...
4061
- def flatten (self , order : _OrderKACF = ...) -> matrix [Any , _DType_co ]: ...
4061
+ def squeeze (self , axis : None | _ShapeLike = ...) -> matrix [_Shape2D , _DType_co ]: ...
4062
+ def tolist (self : matrix [_Shape2D , dtype [_SupportsItem [_T ]]]) -> list [list [_T ]]: ... # type: ignore[typevar]
4063
+ def ravel (self , order : _OrderKACF = ...) -> matrix [_Shape2D , _DType_co ]: ...
4064
+ def flatten (self , order : _OrderKACF = ...) -> matrix [_Shape2D , _DType_co ]: ...
4062
4065
4063
4066
@property
4064
- def T (self ) -> matrix [Any , _DType_co ]: ...
4067
+ def T (self ) -> matrix [_Shape2D , _DType_co ]: ...
4065
4068
@property
4066
- def I (self ) -> matrix [Any , Any ]: ...
4069
+ def I (self ) -> matrix [_Shape2D , Any ]: ...
4067
4070
@property
4068
4071
def A (self ) -> ndarray [_Shape2DType_co , _DType_co ]: ...
4069
4072
@property
4070
- def A1 (self ) -> ndarray [Any , _DType_co ]: ...
4073
+ def A1 (self ) -> ndarray [_Shape , _DType_co ]: ...
4071
4074
@property
4072
- def H (self ) -> matrix [Any , _DType_co ]: ...
4073
- def getT (self ) -> matrix [Any , _DType_co ]: ...
4074
- def getI (self ) -> matrix [Any , Any ]: ...
4075
+ def H (self ) -> matrix [_Shape2D , _DType_co ]: ...
4076
+ def getT (self ) -> matrix [_Shape2D , _DType_co ]: ...
4077
+ def getI (self ) -> matrix [_Shape2D , Any ]: ...
4075
4078
def getA (self ) -> ndarray [_Shape2DType_co , _DType_co ]: ...
4076
- def getA1 (self ) -> ndarray [Any , _DType_co ]: ...
4077
- def getH (self ) -> matrix [Any , _DType_co ]: ...
4079
+ def getA1 (self ) -> ndarray [_Shape , _DType_co ]: ...
4080
+ def getH (self ) -> matrix [_Shape2D , _DType_co ]: ...
4078
4081
4079
4082
_CharType = TypeVar ("_CharType" , str_ , bytes_ )
4080
4083
_CharDType = TypeVar ("_CharDType" , dtype [str_ ], dtype [bytes_ ])
0 commit comments