@@ -24,10 +24,10 @@ def func(i: int, j: int, **kwargs: object) -> MyArray[np.float64]: ...
24
24
assert_type (np .array (A ), _nt .Array [np .float64 ])
25
25
assert_type (np .array (B ), _nt .Array1D [np .float64 ])
26
26
assert_type (np .array (D ), _nt .Array1D [np .float64 | np .int64 ])
27
- assert_type (np .array ([1 , 1.0 ]), _nt .Array [ Any ] )
28
- assert_type (np .array (deque ([1 , 2 , 3 ])), _nt .Array [ Any ] )
27
+ assert_type (np .array ([1 , 1.0 ]), _nt .Array )
28
+ assert_type (np .array (deque ([1 , 2 , 3 ])), _nt .Array )
29
29
assert_type (np .array (A , dtype = np .int64 ), _nt .Array [np .int64 ])
30
- assert_type (np .array (A , dtype = "c16" ), _nt .Array [ Any ] )
30
+ assert_type (np .array (A , dtype = "c16" ), _nt .Array )
31
31
assert_type (np .array (A , like = A ), _nt .Array [np .float64 ])
32
32
assert_type (np .array (A , subok = True ), _nt .Array [np .float64 ])
33
33
assert_type (np .array (B , subok = True ), MyArray [np .float64 ])
@@ -36,68 +36,68 @@ assert_type(np.array(B, subok=True, ndmin=1), MyArray[np.float64])
36
36
37
37
assert_type (np .zeros ([1 , 5 , 6 ]), _nt .Array [np .float64 ])
38
38
assert_type (np .zeros ([1 , 5 , 6 ], dtype = np .int64 ), _nt .Array [np .int64 ])
39
- assert_type (np .zeros ([1 , 5 , 6 ], dtype = "c16" ), _nt .Array [ Any ] )
39
+ assert_type (np .zeros ([1 , 5 , 6 ], dtype = "c16" ), _nt .Array )
40
40
41
41
assert_type (np .empty ([1 , 5 , 6 ]), _nt .Array [np .float64 ])
42
42
assert_type (np .empty ([1 , 5 , 6 ], dtype = np .int64 ), _nt .Array [np .int64 ])
43
- assert_type (np .empty ([1 , 5 , 6 ], dtype = "c16" ), _nt .Array [ Any ] )
43
+ assert_type (np .empty ([1 , 5 , 6 ], dtype = "c16" ), _nt .Array )
44
44
45
45
assert_type (np .concatenate (A ), _nt .Array [np .float64 ])
46
- assert_type (np .concatenate ([A , A ]), _nt .Array [Any ]) # pyright : ignore[reportAssertTypeFailure ] # _nt.Array[np.float64]
47
- assert_type (np .concatenate ([[1 ], A ]), _nt .Array [ Any ] )
48
- assert_type (np .concatenate ([[1 ], [1 ]]), _nt .Array [ Any ] )
46
+ assert_type (np .concatenate ([A , A ]), _nt .Array [np . float64 ]) # type : ignore[assert-type ] # mypy fail
47
+ assert_type (np .concatenate ([[1 ], A ]), _nt .Array )
48
+ assert_type (np .concatenate ([[1 ], [1 ]]), _nt .Array )
49
49
assert_type (np .concatenate ((A , A )), _nt .Array [np .float64 ])
50
- assert_type (np .concatenate (([1 ], [1 ])), _nt .Array [ Any ] )
51
- assert_type (np .concatenate ([1 , 1.0 ]), _nt .Array [ Any ] )
50
+ assert_type (np .concatenate (([1 ], [1 ])), _nt .Array )
51
+ assert_type (np .concatenate ([1 , 1.0 ]), _nt .Array )
52
52
assert_type (np .concatenate (A , dtype = np .int64 ), _nt .Array [np .int64 ])
53
- assert_type (np .concatenate (A , dtype = "c16" ), _nt .Array [ Any ] )
53
+ assert_type (np .concatenate (A , dtype = "c16" ), _nt .Array )
54
54
assert_type (np .concatenate ([1 , 1.0 ], out = A ), _nt .Array [np .float64 ])
55
55
56
56
assert_type (np .asarray (A ), _nt .Array [np .float64 ])
57
57
assert_type (np .asarray (B ), _nt .Array1D [np .float64 ])
58
- assert_type (np .asarray ([1 , 1.0 ]), _nt .Array [ Any ] )
58
+ assert_type (np .asarray ([1 , 1.0 ]), _nt .Array )
59
59
assert_type (np .asarray (A , dtype = np .int64 ), _nt .Array [np .int64 ])
60
- assert_type (np .asarray (A , dtype = "c16" ), _nt .Array [ Any ] )
60
+ assert_type (np .asarray (A , dtype = "c16" ), _nt .Array )
61
61
62
62
assert_type (np .asanyarray (A ), _nt .Array [np .float64 ])
63
63
assert_type (np .asanyarray (B ), MyArray [np .float64 ])
64
- assert_type (np .asanyarray ([1 , 1.0 ]), _nt .Array [ Any ] )
64
+ assert_type (np .asanyarray ([1 , 1.0 ]), _nt .Array )
65
65
assert_type (np .asanyarray (A , dtype = np .int64 ), _nt .Array [np .int64 ])
66
- assert_type (np .asanyarray (A , dtype = "c16" ), _nt .Array [ Any ] )
66
+ assert_type (np .asanyarray (A , dtype = "c16" ), _nt .Array )
67
67
68
68
assert_type (np .ascontiguousarray (A ), _nt .Array [np .float64 ])
69
69
assert_type (np .ascontiguousarray (B ), _nt .Array1D [np .float64 ])
70
- assert_type (np .ascontiguousarray ([1 , 1.0 ]), _nt .Array [ Any ] )
70
+ assert_type (np .ascontiguousarray ([1 , 1.0 ]), _nt .Array )
71
71
assert_type (np .ascontiguousarray (A , dtype = np .int64 ), _nt .Array [np .int64 ])
72
- assert_type (np .ascontiguousarray (A , dtype = "c16" ), _nt .Array [ Any ] )
72
+ assert_type (np .ascontiguousarray (A , dtype = "c16" ), _nt .Array )
73
73
74
74
assert_type (np .asfortranarray (A ), _nt .Array [np .float64 ])
75
75
assert_type (np .asfortranarray (B ), _nt .Array1D [np .float64 ])
76
- assert_type (np .asfortranarray ([1 , 1.0 ]), _nt .Array [ Any ] )
76
+ assert_type (np .asfortranarray ([1 , 1.0 ]), _nt .Array )
77
77
assert_type (np .asfortranarray (A , dtype = np .int64 ), _nt .Array [np .int64 ])
78
- assert_type (np .asfortranarray (A , dtype = "c16" ), _nt .Array [ Any ] )
78
+ assert_type (np .asfortranarray (A , dtype = "c16" ), _nt .Array )
79
79
80
80
assert_type (np .fromstring ("1 1 1" , sep = " " ), _nt .Array [np .float64 ])
81
81
assert_type (np .fromstring (b"1 1 1" , sep = " " ), _nt .Array [np .float64 ])
82
82
assert_type (np .fromstring ("1 1 1" , dtype = np .int64 , sep = " " ), _nt .Array [np .int64 ])
83
83
assert_type (np .fromstring (b"1 1 1" , dtype = np .int64 , sep = " " ), _nt .Array [np .int64 ])
84
- assert_type (np .fromstring ("1 1 1" , dtype = "c16" , sep = " " ), _nt .Array [ Any ] )
85
- assert_type (np .fromstring (b"1 1 1" , dtype = "c16" , sep = " " ), _nt .Array [ Any ] )
84
+ assert_type (np .fromstring ("1 1 1" , dtype = "c16" , sep = " " ), _nt .Array )
85
+ assert_type (np .fromstring (b"1 1 1" , dtype = "c16" , sep = " " ), _nt .Array )
86
86
87
87
assert_type (np .fromfile ("test.txt" , sep = " " ), _nt .Array [np .float64 ])
88
88
assert_type (np .fromfile ("test.txt" , dtype = np .int64 , sep = " " ), _nt .Array [np .int64 ])
89
- assert_type (np .fromfile ("test.txt" , dtype = "c16" , sep = " " ), _nt .Array [ Any ] )
89
+ assert_type (np .fromfile ("test.txt" , dtype = "c16" , sep = " " ), _nt .Array )
90
90
with open ("test.txt" , encoding = "utf-8" ) as f :
91
91
assert_type (np .fromfile (f , sep = " " ), _nt .Array [np .float64 ])
92
92
assert_type (np .fromfile (b"test.txt" , sep = " " ), _nt .Array [np .float64 ])
93
93
assert_type (np .fromfile (Path ("test.txt" ), sep = " " ), _nt .Array [np .float64 ])
94
94
95
95
assert_type (np .fromiter ("12345" , np .float64 ), _nt .Array [np .float64 ])
96
- assert_type (np .fromiter ("12345" , float ), _nt .Array [ Any ] )
96
+ assert_type (np .fromiter ("12345" , float ), _nt .Array )
97
97
98
98
assert_type (np .frombuffer (A ), _nt .Array [np .float64 ])
99
99
assert_type (np .frombuffer (A , dtype = np .int64 ), _nt .Array [np .int64 ])
100
- assert_type (np .frombuffer (A , dtype = "c16" ), _nt .Array [ Any ] )
100
+ assert_type (np .frombuffer (A , dtype = "c16" ), _nt .Array )
101
101
102
102
assert_type (np .arange (False , True ), _nt .Array1D [np .int_ ])
103
103
assert_type (np .arange (10 ), _nt .Array1D [np .int_ ])
@@ -115,7 +115,7 @@ assert_type(np.arange(0, 10, dtype="f8"), _nt.Array1D[np.float64])
115
115
assert_type (np .require (A ), _nt .Array [np .float64 ])
116
116
assert_type (np .require (B ), MyArray [np .float64 ])
117
117
assert_type (np .require (B , requirements = None ), MyArray [np .float64 ])
118
- assert_type (np .require (B , dtype = int ), _nt .Array [ Any ] )
118
+ assert_type (np .require (B , dtype = int ), _nt .Array )
119
119
assert_type (np .require (B , requirements = "E" ), _nt .Array [np .float64 ])
120
120
assert_type (np .require (B , requirements = ["ENSUREARRAY" ]), _nt .Array [np .float64 ])
121
121
assert_type (np .require (B , requirements = {"F" , "E" }), _nt .Array [np .float64 ])
@@ -127,28 +127,28 @@ assert_type(np.require(C), _nt.Array[np.intp])
127
127
assert_type (np .linspace (0 , 10 ), _nt .Array [np .floating ])
128
128
assert_type (np .linspace (0 , 10j ), _nt .Array [np .inexact ])
129
129
assert_type (np .linspace (0 , 10 , dtype = np .int64 ), _nt .Array [np .int64 ])
130
- assert_type (np .linspace (0 , 10 , dtype = int ), _nt .Array [ Any ] )
130
+ assert_type (np .linspace (0 , 10 , dtype = int ), _nt .Array )
131
131
assert_type (np .linspace (0 , 10 , retstep = True ), tuple [_nt .Array [np .floating ], np .floating ])
132
132
assert_type (np .linspace (0j , 10 , retstep = True ), tuple [_nt .Array [np .inexact ], np .inexact ])
133
133
assert_type (np .linspace (0 , 10 , retstep = True , dtype = np .int64 ), tuple [_nt .Array [np .int64 ], np .int64 ])
134
- assert_type (np .linspace (0j , 10 , retstep = True , dtype = int ), tuple [_nt .Array [ Any ] , Any ])
134
+ assert_type (np .linspace (0j , 10 , retstep = True , dtype = int ), tuple [_nt .Array , Any ])
135
135
136
136
assert_type (np .logspace (0 , 10 ), _nt .Array [np .floating ])
137
137
assert_type (np .logspace (0 , 10j ), _nt .Array [np .inexact ])
138
138
assert_type (np .logspace (0 , 10 , dtype = np .int64 ), _nt .Array [np .int64 ])
139
- assert_type (np .logspace (0 , 10 , dtype = int ), _nt .Array [ Any ] )
139
+ assert_type (np .logspace (0 , 10 , dtype = int ), _nt .Array )
140
140
141
141
assert_type (np .geomspace (0 , 10 ), _nt .Array [np .floating ])
142
142
assert_type (np .geomspace (0 , 10j ), _nt .Array [np .inexact ])
143
143
assert_type (np .geomspace (0 , 10 , dtype = np .int64 ), _nt .Array [np .int64 ])
144
- assert_type (np .geomspace (0 , 10 , dtype = int ), _nt .Array [ Any ] )
144
+ assert_type (np .geomspace (0 , 10 , dtype = int ), _nt .Array )
145
145
146
146
assert_type (np .empty_like (A ), _nt .Array [np .float64 ])
147
147
assert_type (np .empty_like (A , dtype = float ), _nt .Array [np .float64 ])
148
- assert_type (np .empty_like (A , shape = (2 , 2 )), _nt .Array [np .float64 , _nt . Shape2 ])
148
+ assert_type (np .empty_like (A , shape = (2 , 2 )), _nt .Array2D [np .float64 ])
149
149
assert_type (np .empty_like (A , dtype = np .int64 ), _nt .Array [np .int64 ])
150
150
assert_type (np .empty_like (A , dtype = np .int64 , shape = (2 , 2 )), _nt .Array [np .int64 , _nt .Shape2 ])
151
- assert_type (np .empty_like (A , dtype = "c16" ), _nt .Array [ Any ] )
151
+ assert_type (np .empty_like (A , dtype = "c16" ), _nt .Array )
152
152
assert_type (np .empty_like (A , dtype = "c16" , shape = (2 , 2 )), np .ndarray [_nt .Shape2 , np .dtype ])
153
153
assert_type (np .empty_like (B ), MyArray [np .float64 ])
154
154
assert_type (np .empty_like (B , dtype = np .int64 ), _nt .Array [np .int64 ])
@@ -171,10 +171,10 @@ assert_type(np.empty_like([[[4j]]]), _nt.Array3D[np.complex128])
171
171
172
172
assert_type (np .zeros_like (A ), _nt .Array [np .float64 ])
173
173
assert_type (np .zeros_like (A , dtype = float ), _nt .Array [np .float64 ])
174
- assert_type (np .zeros_like (A , shape = (2 , 2 )), _nt .Array [np .float64 , _nt . Shape2 ])
174
+ assert_type (np .zeros_like (A , shape = (2 , 2 )), _nt .Array2D [np .float64 ])
175
175
assert_type (np .zeros_like (A , dtype = np .int64 ), _nt .Array [np .int64 ])
176
176
assert_type (np .zeros_like (A , dtype = np .int64 , shape = (2 , 2 )), _nt .Array [np .int64 , _nt .Shape2 ])
177
- assert_type (np .zeros_like (A , dtype = "c16" ), _nt .Array [ Any ] )
177
+ assert_type (np .zeros_like (A , dtype = "c16" ), _nt .Array )
178
178
assert_type (np .zeros_like (A , dtype = "c16" , shape = (2 , 2 )), np .ndarray [_nt .Shape2 , np .dtype ])
179
179
assert_type (np .zeros_like (B ), MyArray [np .float64 ])
180
180
assert_type (np .zeros_like (B , dtype = np .int64 ), _nt .Array [np .int64 ])
@@ -197,10 +197,10 @@ assert_type(np.zeros_like([[[4j]]]), _nt.Array3D[np.complex128])
197
197
198
198
assert_type (np .ones_like (A ), _nt .Array [np .float64 ])
199
199
assert_type (np .ones_like (A , dtype = float ), _nt .Array [np .float64 ])
200
- assert_type (np .ones_like (A , shape = (2 , 2 )), _nt .Array [np .float64 , _nt . Shape2 ])
200
+ assert_type (np .ones_like (A , shape = (2 , 2 )), _nt .Array2D [np .float64 ])
201
201
assert_type (np .ones_like (A , dtype = np .int64 ), _nt .Array [np .int64 ])
202
202
assert_type (np .ones_like (A , dtype = np .int64 , shape = (2 , 2 )), _nt .Array [np .int64 , _nt .Shape2 ])
203
- assert_type (np .ones_like (A , dtype = "c16" ), _nt .Array [ Any ] )
203
+ assert_type (np .ones_like (A , dtype = "c16" ), _nt .Array )
204
204
assert_type (np .ones_like (A , dtype = "c16" , shape = (2 , 2 )), np .ndarray [_nt .Shape2 , np .dtype ])
205
205
assert_type (np .ones_like (B ), MyArray [np .float64 ])
206
206
assert_type (np .ones_like (B , dtype = np .int64 ), _nt .Array [np .int64 ])
@@ -223,7 +223,7 @@ assert_type(np.ones_like([[[4j]]]), _nt.Array3D[np.complex128])
223
223
224
224
assert_type (np .full_like (A , i8 ), _nt .Array [np .float64 ])
225
225
assert_type (np .full_like (C , i8 ), _nt .Array1D [np .intp ])
226
- assert_type (np .full_like (A , i8 , dtype = int ), _nt .Array [ Any ] )
226
+ assert_type (np .full_like (A , i8 , dtype = int ), _nt .Array )
227
227
assert_type (np .full_like (B , i8 ), MyArray [np .float64 ])
228
228
assert_type (np .full_like (B , i8 , dtype = np .int64 ), _nt .Array [np .int64 ])
229
229
@@ -240,8 +240,8 @@ assert_type(np.ones(_shape_2d), _nt.Array[np.float64, _nt.Shape2])
240
240
assert_type (np .ones (_shape_nd ), np .ndarray [_nt .Shape , np .dtype [np .float64 ]])
241
241
assert_type (np .ones (_shape_1d , dtype = np .int64 ), _nt .Array1D [np .int64 ])
242
242
assert_type (np .ones (_shape_like ), _nt .Array [np .float64 ])
243
- assert_type (np .ones (_shape_like , dtype = np .dtypes .StringDType ()), np .ndarray [Any , np .dtypes .StringDType ])
244
- assert_type (np .ones (_shape_like , dtype = int ), _nt .Array [ Any ] )
243
+ assert_type (np .ones (_shape_like , dtype = np .dtypes .StringDType ()), np .ndarray [_nt . AnyShape , np .dtypes .StringDType ])
244
+ assert_type (np .ones (_shape_like , dtype = int ), _nt .Array )
245
245
246
246
assert_type (np .full (_size , i8 ), _nt .Array1D [np .int64 ])
247
247
assert_type (np .full (_shape_2d , i8 ), _nt .Array [np .int64 , _nt .Shape2 ])
@@ -265,12 +265,12 @@ assert_type(np.identity(10, dtype=np.int64), _nt.Array2D[np.int64])
265
265
assert_type (np .identity (10 , dtype = int ), _nt .Array2D )
266
266
267
267
assert_type (np .atleast_1d (A ), _nt .Array [np .float64 ])
268
- assert_type (np .atleast_1d (C ), _nt .Array [ Any ] )
268
+ assert_type (np .atleast_1d (C ), _nt .Array )
269
269
assert_type (np .atleast_1d (A , A ), tuple [_nt .Array [np .float64 ], _nt .Array [np .float64 ]])
270
- assert_type (np .atleast_1d (A , C ), tuple [_nt .Array [ Any ] , _nt .Array [ Any ] ])
271
- assert_type (np .atleast_1d (C , C ), tuple [_nt .Array [ Any ] , _nt .Array [ Any ] ])
270
+ assert_type (np .atleast_1d (A , C ), tuple [_nt .Array , _nt .Array ])
271
+ assert_type (np .atleast_1d (C , C ), tuple [_nt .Array , _nt .Array ])
272
272
assert_type (np .atleast_1d (A , A , A ), tuple [_nt .Array [np .float64 ], ...])
273
- assert_type (np .atleast_1d (C , C , C ), tuple [_nt .Array [ Any ] , ...])
273
+ assert_type (np .atleast_1d (C , C , C ), tuple [_nt .Array , ...])
274
274
275
275
assert_type (np .atleast_2d (A ), _nt .Array [np .float64 ])
276
276
assert_type (np .atleast_2d (A , A ), tuple [_nt .Array [np .float64 ], _nt .Array [np .float64 ]])
@@ -280,28 +280,28 @@ assert_type(np.atleast_3d(A), _nt.Array[np.float64])
280
280
assert_type (np .atleast_3d (A , A ), tuple [_nt .Array [np .float64 ], _nt .Array [np .float64 ]])
281
281
assert_type (np .atleast_3d (A , A , A ), tuple [_nt .Array [np .float64 ], ...])
282
282
283
- assert_type (np .vstack ([A , A ]), _nt .Array [np .float64 ])
283
+ assert_type (np .vstack ([A , A ]), _nt .Array [np .float64 ]) # type: ignore[assert-type] # mypy fail
284
284
assert_type (np .vstack ([A , A ], dtype = np .float32 ), _nt .Array [np .float32 ])
285
- assert_type (np .vstack ([A , C ]), _nt .Array [ Any ] )
286
- assert_type (np .vstack ([C , C ]), _nt .Array [ Any ] )
285
+ assert_type (np .vstack ([A , C ]), _nt .Array )
286
+ assert_type (np .vstack ([C , C ]), _nt .Array )
287
287
288
- assert_type (np .hstack ([A , A ]), _nt .Array [np .float64 ])
288
+ assert_type (np .hstack ([A , A ]), _nt .Array [np .float64 ]) # type: ignore[assert-type] # mypy fail
289
289
assert_type (np .hstack ([A , A ], dtype = np .float32 ), _nt .Array [np .float32 ])
290
290
291
- assert_type (np .stack ([A , A ]), _nt .Array [np .float64 ])
291
+ assert_type (np .stack ([A , A ]), _nt .Array [np .float64 ]) # type: ignore[assert-type] # mypy fail
292
292
assert_type (np .stack ([A , A ], dtype = np .float32 ), _nt .Array [np .float32 ])
293
- assert_type (np .stack ([A , C ]), _nt .Array [ Any ] )
294
- assert_type (np .stack ([C , C ]), _nt .Array [ Any ] )
295
- assert_type (np .stack ([A , A ], axis = 0 ), _nt .Array [np .float64 ])
293
+ assert_type (np .stack ([A , C ]), _nt .Array )
294
+ assert_type (np .stack ([C , C ]), _nt .Array )
295
+ assert_type (np .stack ([A , A ], axis = 0 ), _nt .Array [np .float64 ]) # type: ignore[assert-type] # mypy fail
296
296
assert_type (np .stack ([A , A ], out = B ), MyArray [np .float64 ])
297
297
298
- assert_type (np .block ([[A , A ], [A , A ]]), _nt .Array [ Any ] ) # pyright: ignore[reportAssertTypeFailure] # _nt.Array[np.float64]
299
- assert_type (np .block (C ), _nt .Array [ Any ] )
298
+ assert_type (np .block ([[A , A ], [A , A ]]), _nt .Array ) # pyright: ignore[reportAssertTypeFailure] # _nt.Array[np.float64]
299
+ assert_type (np .block (C ), _nt .Array )
300
300
301
301
if sys .version_info >= (3 , 12 ):
302
302
from collections .abc import Buffer
303
303
304
- def create_array (obj : npt .ArrayLike ) -> _nt .Array [ Any ] : ...
304
+ def create_array (obj : npt .ArrayLike ) -> _nt .Array : ...
305
305
306
306
buffer : Buffer
307
- assert_type (create_array (buffer ), _nt .Array [ Any ] )
307
+ assert_type (create_array (buffer ), _nt .Array )
0 commit comments