@@ -1093,35 +1093,11 @@ class _SupportsItem(Protocol[_T_co]):
1093
1093
class _SupportsDLPack (Protocol [_T_contra ]):
1094
1094
def __dlpack__ (self , / , * , stream : _T_contra | None = None ) -> CapsuleType : ...
1095
1095
1096
- @type_check_only
1097
- class _HasShape (Protocol [_ShapeT_co ]):
1098
- @property
1099
- def shape (self , / ) -> _ShapeT_co : ...
1100
-
1101
1096
@type_check_only
1102
1097
class _HasDType (Protocol [_T_co ]):
1103
1098
@property
1104
1099
def dtype (self , / ) -> _T_co : ...
1105
1100
1106
- @type_check_only
1107
- class _HasShapeAndSupportsItem (_HasShape [_ShapeT_co ], _SupportsItem [_T_co ], Protocol [_ShapeT_co , _T_co ]): ...
1108
-
1109
- # matches any `x` on `x.type.item() -> _T_co`, e.g. `dtype[np.int8]` gives `_T_co: int`
1110
- @type_check_only
1111
- class _HasTypeWithItem (Protocol [_T_co ]):
1112
- @property
1113
- def type (self , / ) -> type [_SupportsItem [_T_co ]]: ...
1114
-
1115
- # matches any `x` on `x.shape: _ShapeT_co` and `x.dtype.type.item() -> _T_co`,
1116
- # useful for capturing the item-type (`_T_co`) of the scalar-type of an array with
1117
- # specific shape (`_ShapeT_co`).
1118
- @type_check_only
1119
- class _HasShapeAndDTypeWithItem (Protocol [_ShapeT_co , _T_co ]):
1120
- @property
1121
- def shape (self , / ) -> _ShapeT_co : ...
1122
- @property
1123
- def dtype (self , / ) -> _HasTypeWithItem [_T_co ]: ...
1124
-
1125
1101
@type_check_only
1126
1102
class _HasRealAndImag (Protocol [_RealT_co , _ImagT_co ]):
1127
1103
@property
@@ -2204,29 +2180,26 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DType_co]):
2204
2180
@property
2205
2181
def flat (self ) -> flatiter [Self ]: ...
2206
2182
2207
- @overload # special casing for `StringDType`, which has no scalar type
2208
- def item (self : ndarray [Any , dtypes .StringDType ], / ) -> str : ...
2209
- @overload
2210
- def item (self : ndarray [Any , dtypes .StringDType ], arg0 : SupportsIndex | tuple [SupportsIndex , ...] = ..., / ) -> str : ...
2211
- @overload
2212
- def item (self : ndarray [Any , dtypes .StringDType ], / , * args : SupportsIndex ) -> str : ...
2213
2183
@overload # use the same output type as that of the underlying `generic`
2214
- def item (self : _HasShapeAndDTypeWithItem [Any , _T ], / ) -> _T : ...
2215
- @overload
2216
- def item (self : _HasShapeAndDTypeWithItem [Any , _T ], arg0 : SupportsIndex | tuple [SupportsIndex , ...] = ..., / ) -> _T : ...
2217
- @overload
2218
- def item (self : _HasShapeAndDTypeWithItem [Any , _T ], / , * args : SupportsIndex ) -> _T : ...
2184
+ def item (self : NDArray [generic [_T ]], i0 : SupportsIndex | tuple [SupportsIndex , ...] = ..., / , * args : SupportsIndex ) -> _T : ...
2185
+ @overload # special casing for `StringDType`, which has no scalar type
2186
+ def item (
2187
+ self : ndarray [Any , dtypes .StringDType ],
2188
+ arg0 : SupportsIndex | tuple [SupportsIndex , ...] = ...,
2189
+ / ,
2190
+ * args : SupportsIndex ,
2191
+ ) -> str : ...
2219
2192
2220
2193
@overload
2221
- def tolist (self : _HasShapeAndSupportsItem [tuple [()], _T ], / ) -> _T : ...
2194
+ def tolist (self : ndarray [tuple [()], dtype [ generic [ _T ]] ], / ) -> _T : ...
2222
2195
@overload
2223
- def tolist (self : _HasShapeAndSupportsItem [tuple [int ], _T ], / ) -> list [_T ]: ...
2196
+ def tolist (self : ndarray [tuple [int ], dtype [ generic [ _T ]] ], / ) -> list [_T ]: ...
2224
2197
@overload
2225
- def tolist (self : _HasShapeAndSupportsItem [tuple [int , int ], _T ], / ) -> list [list [_T ]]: ...
2198
+ def tolist (self : ndarray [tuple [int , int ], dtype [ generic [ _T ]] ], / ) -> list [list [_T ]]: ...
2226
2199
@overload
2227
- def tolist (self : _HasShapeAndSupportsItem [tuple [int , int , int ], _T ], / ) -> list [list [list [_T ]]]: ...
2200
+ def tolist (self : ndarray [tuple [int , int , int ], dtype [ generic [ _T ]] ], / ) -> list [list [list [_T ]]]: ...
2228
2201
@overload
2229
- def tolist (self : _HasShapeAndSupportsItem [ Any , _T ], / ) -> _T | list [ _T ] | list [ list [ _T ]] | list [ list [ list [ Any ]]] : ...
2202
+ def tolist (self , / ) -> Any : ...
2230
2203
2231
2204
@overload
2232
2205
def resize (self , new_shape : _ShapeLike , / , * , refcheck : builtins .bool = ...) -> None : ...
@@ -5379,7 +5352,7 @@ class matrix(ndarray[_2DShapeT_co, _DType_co]):
5379
5352
def ptp (self , axis : None | _ShapeLike = ..., out : _ArrayT = ...) -> _ArrayT : ...
5380
5353
5381
5354
def squeeze (self , axis : None | _ShapeLike = ...) -> matrix [_2D , _DType_co ]: ...
5382
- def tolist (self : _SupportsItem [ _T ]) -> list [list [_T ]]: ...
5355
+ def tolist (self : matrix [ Any , dtype [ generic [ _T ]]] ) -> list [list [_T ]]: ... # pyright: ignore[reportIncompatibleMethodOverride]
5383
5356
def ravel (self , / , order : _OrderKACF = "C" ) -> matrix [tuple [L [1 ], int ], _DType_co ]: ... # pyright: ignore[reportIncompatibleMethodOverride]
5384
5357
def flatten (self , / , order : _OrderKACF = "C" ) -> matrix [tuple [L [1 ], int ], _DType_co ]: ... # pyright: ignore[reportIncompatibleMethodOverride]
5385
5358
0 commit comments