@@ -2193,17 +2193,8 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
2193
2193
axis : None | SupportsIndex = ...,
2194
2194
) -> ndarray [_Shape , _DType_co ]: ...
2195
2195
2196
- # TODO: use `tuple[int]` as shape type once covariant (#26081)
2197
- def flatten (
2198
- self ,
2199
- order : _OrderKACF = ...,
2200
- ) -> ndarray [_Shape , _DType_co ]: ...
2201
-
2202
- # TODO: use `tuple[int]` as shape type once covariant (#26081)
2203
- def ravel (
2204
- self ,
2205
- order : _OrderKACF = ...,
2206
- ) -> ndarray [_Shape , _DType_co ]: ...
2196
+ def flatten (self , / , order : _OrderKACF = "C" ) -> ndarray [tuple [int ], _DType_co ]: ...
2197
+ def ravel (self , / , order : _OrderKACF = "C" ) -> ndarray [tuple [int ], _DType_co ]: ...
2207
2198
2208
2199
@overload
2209
2200
def reshape (
@@ -3099,11 +3090,10 @@ _NBit_fc = TypeVar("_NBit_fc", _NBitHalf, _NBitSingle, _NBitDouble, _NBitLongDou
3099
3090
class generic (_ArrayOrScalarCommon ):
3100
3091
@abstractmethod
3101
3092
def __init__ (self , * args : Any , ** kwargs : Any ) -> None : ...
3102
- # TODO: use `tuple[()]` as shape type once covariant (#26081)
3103
3093
@overload
3104
- def __array__ (self , dtype : None = ... , / ) -> NDArray [ Self ]: ...
3094
+ def __array__ (self , dtype : None = None , / ) -> ndarray [ tuple [()], dtype [ Self ] ]: ...
3105
3095
@overload
3106
- def __array__ (self , dtype : _DType , / ) -> ndarray [_Shape , _DType ]: ...
3096
+ def __array__ (self , dtype : _DType , / ) -> ndarray [tuple [()] , _DType ]: ...
3107
3097
def __hash__ (self ) -> int : ...
3108
3098
@property
3109
3099
def base (self ) -> None : ...
@@ -3117,7 +3107,7 @@ class generic(_ArrayOrScalarCommon):
3117
3107
def strides (self ) -> tuple [()]: ...
3118
3108
def byteswap (self , inplace : L [False ] = ...) -> Self : ...
3119
3109
@property
3120
- def flat (self ) -> flatiter [NDArray [ Self ]]: ...
3110
+ def flat (self ) -> flatiter [ndarray [ tuple [ int ], dtype [ Self ] ]]: ...
3121
3111
3122
3112
if sys .version_info >= (3 , 12 ):
3123
3113
def __buffer__ (self , flags : int , / ) -> memoryview : ...
@@ -3201,8 +3191,8 @@ class generic(_ArrayOrScalarCommon):
3201
3191
) -> _NdArraySubClass : ...
3202
3192
3203
3193
def repeat (self , repeats : _ArrayLikeInt_co , axis : None | SupportsIndex = ...) -> NDArray [Self ]: ...
3204
- def flatten (self , order : _OrderKACF = ... ) -> NDArray [ Self ]: ...
3205
- def ravel (self , order : _OrderKACF = ... ) -> NDArray [ Self ]: ...
3194
+ def flatten (self , / , order : _OrderKACF = "C" ) -> ndarray [ tuple [ int ], dtype [ Self ] ]: ...
3195
+ def ravel (self , / , order : _OrderKACF = "C" ) -> ndarray [ tuple [ int ], dtype [ Self ] ]: ...
3206
3196
3207
3197
@overload
3208
3198
def reshape (self , shape : _ShapeLike , / , * , order : _OrderACF = ...) -> NDArray [Self ]: ...
@@ -4480,13 +4470,12 @@ class poly1d:
4480
4470
@coefficients .setter
4481
4471
def coefficients (self , value : NDArray [Any ]) -> None : ...
4482
4472
4483
- __hash__ : ClassVar [None ] # type: ignore
4473
+ __hash__ : ClassVar [None ] # type: ignore[assignment] # pyright: ignore[reportIncompatibleMethodOverride]
4484
4474
4485
- # TODO: use `tuple[int]` as shape type once covariant (#26081)
4486
4475
@overload
4487
- def __array__ (self , t : None = ... , copy : None | bool = ... ) -> NDArray [ Any ]: ...
4476
+ def __array__ (self , / , t : None = None , copy : builtins . bool | None = None ) -> ndarray [ tuple [ int ], dtype [ Any ] ]: ...
4488
4477
@overload
4489
- def __array__ (self , t : _DType , copy : None | bool = ... ) -> ndarray [_Shape , _DType ]: ...
4478
+ def __array__ (self , / , t : _DType , copy : builtins . bool | None = None ) -> ndarray [tuple [ int ] , _DType ]: ...
4490
4479
4491
4480
@overload
4492
4481
def __call__ (self , val : _ScalarLike_co ) -> Any : ...
@@ -4656,8 +4645,8 @@ class matrix(ndarray[_Shape2DType_co, _DType_co]):
4656
4645
4657
4646
def squeeze (self , axis : None | _ShapeLike = ...) -> matrix [_Shape2D , _DType_co ]: ...
4658
4647
def tolist (self : _SupportsItem [_T ]) -> list [list [_T ]]: ...
4659
- def ravel (self , order : _OrderKACF = ... ) -> matrix [_Shape2D , _DType_co ]: ...
4660
- def flatten (self , order : _OrderKACF = ... ) -> matrix [_Shape2D , _DType_co ]: ...
4648
+ def ravel (self , / , order : _OrderKACF = "C" ) -> matrix [tuple [ L [ 1 ], int ], _DType_co ]: ... # pyright: ignore[reportIncompatibleMethodOverride]
4649
+ def flatten (self , / , order : _OrderKACF = "C" ) -> matrix [tuple [ L [ 1 ], int ], _DType_co ]: ... # pyright: ignore[reportIncompatibleMethodOverride]
4661
4650
4662
4651
@property
4663
4652
def T (self ) -> matrix [_Shape2D , _DType_co ]: ...
0 commit comments