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