1
1
# ruff: noqa: ANN401
2
2
# pyright: reportSelfClsParameterName=false
3
3
from collections .abc import Iterable , Sequence
4
- from types import EllipsisType
5
- from typing import Any , Literal , Protocol , SupportsIndex , TypeAlias , TypeVar , overload , type_check_only
4
+ from typing import Any , ClassVar , Literal , Protocol , SupportsIndex , TypeAlias , overload , type_check_only
6
5
7
6
from _typeshed import StrOrBytesPath
7
+ from typing_extensions import TypeVar
8
8
9
- from numpy import _ByteOrder , _OrderKACF , _SupportsBuffer , dtype , generic , ndarray , void
9
+ import numpy as np
10
+ from numpy import _ByteOrder , _OrderKACF , _SupportsBuffer
10
11
from numpy ._typing import ArrayLike , DTypeLike , NDArray , _ArrayLikeVoid_co , _NestedSequence , _ShapeLike
11
12
12
13
__all__ = [
@@ -22,11 +23,11 @@ __all__ = [
22
23
]
23
24
24
25
_T = TypeVar ("_T" )
25
- _SCT = TypeVar ("_SCT" , bound = generic )
26
- _DType_co = TypeVar ("_DType_co " , bound = dtype [Any ], covariant = True )
26
+ _SCT = TypeVar ("_SCT" , bound = np . generic )
27
+ _DTypeT_co = TypeVar ("_DTypeT_co " , bound = np . dtype [Any ], covariant = True )
27
28
_ShapeT_co = TypeVar ("_ShapeT_co" , bound = tuple [int , ...], covariant = True )
28
29
29
- _RecArray : TypeAlias = recarray [Any , dtype [_SCT ]]
30
+ _RecArray : TypeAlias = recarray [Any , np . dtype [_SCT ]]
30
31
31
32
@type_check_only
32
33
class _SupportsReadInto (Protocol ):
@@ -37,7 +38,7 @@ class _SupportsReadInto(Protocol):
37
38
###
38
39
39
40
# exported in `numpy.rec`
40
- class record (void ):
41
+ class record (np . void ):
41
42
def __getattribute__ (self , attr : str ) -> Any : ...
42
43
def __setattr__ (self , attr : str , val : ArrayLike ) -> None : ...
43
44
def pprint (self ) -> str : ...
@@ -47,10 +48,9 @@ class record(void):
47
48
def __getitem__ (self , key : list [str ]) -> record : ...
48
49
49
50
# exported in `numpy.rec`
50
- class recarray (ndarray [_ShapeT_co , _DType_co ]):
51
- # NOTE: While not strictly mandatory, we're demanding here that arguments
52
- # for the `format_parser`- and `dtype`-based dtype constructors are
53
- # mutually exclusive
51
+ class recarray (np .ndarray [_ShapeT_co , _DTypeT_co ]):
52
+ __name__ : ClassVar [Literal ["record" ]] = "record"
53
+ __module__ : Literal ["numpy" ] = "numpy"
54
54
@overload
55
55
def __new__ (
56
56
subtype ,
@@ -66,7 +66,7 @@ class recarray(ndarray[_ShapeT_co, _DType_co]):
66
66
byteorder : _ByteOrder | None = None ,
67
67
aligned : bool = False ,
68
68
order : _OrderKACF = "C" ,
69
- ) -> recarray [ Any , dtype [ record ] ]: ...
69
+ ) -> _RecArray [ record ]: ...
70
70
@overload
71
71
def __new__ (
72
72
subtype ,
@@ -81,18 +81,20 @@ class recarray(ndarray[_ShapeT_co, _DType_co]):
81
81
byteorder : None = None ,
82
82
aligned : Literal [False ] = False ,
83
83
order : _OrderKACF = "C" ,
84
- ) -> recarray [Any , dtype [ Any ] ]: ...
84
+ ) -> _RecArray [Any ]: ...
85
85
def __array_finalize__ (self , / , obj : object ) -> None : ...
86
86
def __getattribute__ (self , attr : str , / ) -> Any : ...
87
87
def __setattr__ (self , attr : str , val : ArrayLike , / ) -> None : ...
88
- @ overload
89
- def field ( self , / , attr : int | str , val : None = None ) -> Any : ...
88
+
89
+ #
90
90
@overload
91
91
def field (self , / , attr : int | str , val : ArrayLike ) -> None : ...
92
+ @overload
93
+ def field (self , / , attr : int | str , val : None = None ) -> Any : ...
92
94
93
95
# exported in `numpy.rec`
94
96
class format_parser :
95
- dtype : dtype [void ]
97
+ dtype : np . dtype [np . void ]
96
98
def __init__ (
97
99
self ,
98
100
/ ,
@@ -213,6 +215,7 @@ def array(
213
215
dtype : None = None ,
214
216
shape : _ShapeLike | None = None ,
215
217
offset : int = 0 ,
218
+ strides : tuple [int , ...] | None = None ,
216
219
formats : None = None ,
217
220
names : None = None ,
218
221
titles : None = None ,
@@ -226,6 +229,7 @@ def array(
226
229
dtype : DTypeLike ,
227
230
shape : _ShapeLike | None = None ,
228
231
offset : int = 0 ,
232
+ strides : tuple [int , ...] | None = None ,
229
233
formats : None = None ,
230
234
names : None = None ,
231
235
titles : None = None ,
@@ -239,6 +243,7 @@ def array(
239
243
dtype : None = None ,
240
244
shape : _ShapeLike | None = None ,
241
245
offset : int = 0 ,
246
+ strides : tuple [int , ...] | None = None ,
242
247
* ,
243
248
formats : DTypeLike ,
244
249
names : str | Sequence [str ] | None = None ,
@@ -253,6 +258,7 @@ def array(
253
258
dtype : DTypeLike ,
254
259
shape : _ShapeLike ,
255
260
offset : int = 0 ,
261
+ strides : tuple [int , ...] | None = None ,
256
262
formats : None = None ,
257
263
names : None = None ,
258
264
titles : None = None ,
@@ -267,6 +273,7 @@ def array(
267
273
* ,
268
274
shape : _ShapeLike ,
269
275
offset : int = 0 ,
276
+ strides : tuple [int , ...] | None = None ,
270
277
formats : DTypeLike ,
271
278
names : str | Sequence [str ] | None = None ,
272
279
titles : str | Sequence [str ] | None = None ,
@@ -280,6 +287,7 @@ def array(
280
287
dtype : DTypeLike ,
281
288
shape : _ShapeLike | None = None ,
282
289
offset : int = 0 ,
290
+ strides : tuple [int , ...] | None = None ,
283
291
formats : None = None ,
284
292
names : None = None ,
285
293
titles : None = None ,
@@ -293,6 +301,7 @@ def array(
293
301
dtype : None = None ,
294
302
shape : _ShapeLike | None = None ,
295
303
offset : int = 0 ,
304
+ strides : tuple [int , ...] | None = None ,
296
305
* ,
297
306
formats : DTypeLike ,
298
307
names : str | Sequence [str ] | None = None ,
0 commit comments