@@ -10,8 +10,9 @@ import numpy as np
10
10
vectorized_func : np .vectorize
11
11
12
12
f8 : np .float64
13
- AR_LIKE_f8 : list [float ]
14
- AR_LIKE_c16 : list [complex ]
13
+ AR_LIKE_i : list [int ]
14
+ AR_LIKE_f : list [float ]
15
+ AR_LIKE_c : list [complex ]
15
16
AR_LIKE_O : list [Fraction ]
16
17
17
18
AR_i8 : _nt .Array [np .int64 ]
@@ -22,7 +23,7 @@ AR_M: _nt.Array[np.datetime64]
22
23
AR_O : _nt .Array [np .object_ ]
23
24
AR_b : _nt .Array [np .bool ]
24
25
AR_U : _nt .Array [np .str_ ]
25
- CHAR_AR_U : np .char .chararray [tuple [ int , ...] , np .dtype [np .str_ ]]
26
+ CHAR_AR_U : np .char .chararray [_nt . AnyShape , np .dtype [np .str_ ]]
26
27
27
28
AR_b_list : list [_nt .Array [np .bool ]]
28
29
@@ -41,12 +42,12 @@ assert_type(np.vectorize(int), np.vectorize)
41
42
assert_type (np .vectorize (int , otypes = "i" , doc = "doc" , excluded = (), cache = True , signature = None ), np .vectorize )
42
43
43
44
assert_type (np .rot90 (AR_f8 , k = 2 ), _nt .Array [np .float64 ])
44
- assert_type (np .rot90 (AR_LIKE_f8 , axes = (0 , 1 )), _nt .Array [Any ])
45
+ assert_type (np .rot90 (AR_LIKE_f , axes = (0 , 1 )), _nt .Array [Any ])
45
46
46
47
assert_type (np .flip (f8 ), np .float64 )
47
48
assert_type (np .flip (1.0 ), Any )
48
49
assert_type (np .flip (AR_f8 , axis = (0 , 1 )), _nt .Array [np .float64 ])
49
- assert_type (np .flip (AR_LIKE_f8 , axis = 0 ), _nt .Array [Any ])
50
+ assert_type (np .flip (AR_LIKE_f , axis = 0 ), _nt .Array [Any ])
50
51
51
52
assert_type (np .iterable (1 ), bool )
52
53
assert_type (np .iterable ([1 ]), bool )
@@ -61,30 +62,30 @@ assert_type(np.average(AR_f8, axis=0), Any)
61
62
assert_type (np .average (AR_f8 , axis = 0 , returned = True ), tuple [Any , Any ])
62
63
63
64
assert_type (np .asarray_chkfinite (AR_f8 ), _nt .Array [np .float64 ])
64
- assert_type (np .asarray_chkfinite (AR_LIKE_f8 ), _nt .Array [Any ])
65
+ assert_type (np .asarray_chkfinite (AR_LIKE_f ), _nt .Array [Any ])
65
66
assert_type (np .asarray_chkfinite (AR_f8 , dtype = np .float64 ), _nt .Array [np .float64 ])
66
67
assert_type (np .asarray_chkfinite (AR_f8 , dtype = float ), _nt .Array [Any ])
67
68
68
69
assert_type (np .piecewise (AR_f8 , AR_b , [func ]), _nt .Array [np .float64 ])
69
70
assert_type (np .piecewise (AR_f8 , AR_b_list , [func ]), _nt .Array [np .float64 ])
70
71
assert_type (np .piecewise (AR_f8 , AR_b_list , [func ], True , - 1 , kwarg = "" ), _nt .Array [np .float64 ])
71
72
assert_type (np .piecewise (AR_f8 , AR_b_list , [func ], True , arg = - 1 , kwarg = "" ), _nt .Array [np .float64 ])
72
- assert_type (np .piecewise (AR_LIKE_f8 , AR_b_list , [func ]), _nt .Array [Any ])
73
+ assert_type (np .piecewise (AR_LIKE_f , AR_b_list , [func ]), _nt .Array [Any ])
73
74
74
75
assert_type (np .select ([AR_f8 ], [AR_f8 ]), _nt .Array [np .float64 ])
75
76
76
- assert_type (np .copy (AR_LIKE_f8 ), _nt .Array [Any ])
77
+ assert_type (np .copy (AR_LIKE_f ), _nt .Array [Any ])
77
78
assert_type (np .copy (AR_U ), _nt .Array [np .str_ ])
78
79
assert_type (np .copy (CHAR_AR_U ), _nt .Array [np .str_ ])
79
- assert_type (np .copy (CHAR_AR_U , "K" , subok = True ), np .char .chararray [tuple [ int , ...] , np .dtype [np .str_ ]])
80
- assert_type (np .copy (CHAR_AR_U , subok = True ), np .char .chararray [tuple [ int , ...] , np .dtype [np .str_ ]])
80
+ assert_type (np .copy (CHAR_AR_U , "K" , subok = True ), np .char .chararray [_nt . AnyShape , np .dtype [np .str_ ]])
81
+ assert_type (np .copy (CHAR_AR_U , subok = True ), np .char .chararray [_nt . AnyShape , np .dtype [np .str_ ]])
81
82
82
83
assert_type (np .gradient (AR_f8 , axis = None ), Any )
83
- assert_type (np .gradient (AR_LIKE_f8 , edge_order = 2 ), Any )
84
+ assert_type (np .gradient (AR_LIKE_f , edge_order = 2 ), Any )
84
85
85
86
assert_type (np .diff ("bob" , n = 0 ), str )
86
87
assert_type (np .diff (AR_f8 , axis = 0 ), _nt .Array [np .float64 ])
87
- assert_type (np .diff (AR_LIKE_f8 , prepend = 1.5 ), _nt .Array [Any ])
88
+ assert_type (np .diff (AR_LIKE_f , prepend = 1.5 ), _nt .Array [Any ])
88
89
89
90
assert_type (np .interp (1 , [1 ], AR_f8 ), np .float64 )
90
91
assert_type (np .interp (1 , [1 ], [1 ]), np .float64 )
@@ -107,10 +108,10 @@ assert_type(np.unwrap(AR_O), _nt.Array[np.object_])
107
108
assert_type (np .sort_complex (AR_f8 ), _nt .Array [np .complexfloating ])
108
109
109
110
assert_type (np .trim_zeros (AR_f8 ), _nt .Array [np .float64 ])
110
- assert_type (np .trim_zeros (AR_LIKE_f8 ), list [float ])
111
+ assert_type (np .trim_zeros (AR_LIKE_f ), list [float ])
111
112
112
113
assert_type (np .extract (AR_i8 , AR_f8 ), _nt .Array [np .float64 ])
113
- assert_type (np .extract (AR_i8 , AR_LIKE_f8 ), _nt .Array [Any ])
114
+ assert_type (np .extract (AR_i8 , AR_LIKE_f ), _nt .Array [Any ])
114
115
115
116
assert_type (np .place (AR_f8 , mask = AR_i8 , vals = 5.0 ), None )
116
117
@@ -142,7 +143,7 @@ assert_type(np.median(AR_m), np.timedelta64)
142
143
assert_type (np .median (AR_O ), Any )
143
144
assert_type (np .median (AR_f8 , keepdims = True ), Any )
144
145
assert_type (np .median (AR_c16 , axis = 0 ), Any )
145
- assert_type (np .median (AR_LIKE_f8 , out = AR_c16 ), _nt .Array [np .complex128 ])
146
+ assert_type (np .median (AR_LIKE_f , out = AR_c16 ), _nt .Array [np .complex128 ])
146
147
147
148
assert_type (np .percentile (AR_f8 , 50 ), np .floating )
148
149
assert_type (np .percentile (AR_c16 , 50 ), np .complexfloating )
@@ -172,38 +173,45 @@ assert_type(np.quantile(AR_f8, [0.5], keepdims=True), Any)
172
173
assert_type (np .quantile (AR_f8 , [0.5 ], axis = [1 ]), Any )
173
174
assert_type (np .quantile (AR_f8 , [0.5 ], out = AR_c16 ), _nt .Array [np .complex128 ])
174
175
175
- assert_type (np .trapezoid (AR_LIKE_f8 ), np .float64 )
176
- assert_type (np .trapezoid (AR_LIKE_f8 , AR_LIKE_f8 ), np .float64 )
177
- assert_type (np .trapezoid (AR_LIKE_c16 ), np .complexfloating )
178
- assert_type (np .trapezoid (AR_LIKE_c16 , AR_LIKE_f8 ), np .complexfloating )
179
- assert_type (np .trapezoid (AR_LIKE_f8 , AR_LIKE_c16 ), np .complexfloating )
176
+ assert_type (np .trapezoid (AR_LIKE_i ), np .float64 )
177
+ assert_type (np .trapezoid (AR_LIKE_f ), np .float64 )
178
+ assert_type (np .trapezoid (AR_LIKE_f , AR_LIKE_f ), np .float64 )
179
+ assert_type (np .trapezoid (AR_LIKE_f , AR_LIKE_i ), np .float64 )
180
+ assert_type (np .trapezoid (AR_LIKE_i , AR_LIKE_f ), np .float64 )
181
+ assert_type (np .trapezoid (AR_LIKE_c ), np .complexfloating )
182
+ assert_type (np .trapezoid (AR_LIKE_c , AR_LIKE_f ), np .complexfloating )
183
+ assert_type (np .trapezoid (AR_LIKE_f , AR_LIKE_c ), np .complexfloating )
180
184
# pyright bug: https://github.com/microsoft/pyright/issues/9896
181
185
assert_type (np .trapezoid (AR_LIKE_O ), float ) # pyright: ignore[reportAssertTypeFailure]
182
- assert_type (np .trapezoid (AR_LIKE_O , AR_LIKE_f8 ), float ) # pyright: ignore[reportAssertTypeFailure]
183
- assert_type (np .trapezoid (AR_f8 ), np .floating | _nt .Array [np .floating ])
184
- assert_type (np .trapezoid (AR_f8 , AR_f8 ), np .floating | _nt .Array [np .floating ])
185
- assert_type (np .trapezoid (AR_c16 ), np .complexfloating | _nt .Array [np .complexfloating ])
186
- assert_type (np .trapezoid (AR_c16 , AR_c16 ), np .complexfloating | _nt .Array [np .complexfloating ])
186
+ assert_type (np .trapezoid (AR_LIKE_O , AR_LIKE_f ), float ) # pyright: ignore[reportAssertTypeFailure]
187
+ assert_type (np .trapezoid (AR_i8 ), np .float64 | _nt .Array [np .float64 ])
188
+ assert_type (np .trapezoid (AR_i8 , AR_i8 ), np .float64 | _nt .Array [np .float64 ])
189
+ assert_type (np .trapezoid (AR_f8 ), np .float64 | _nt .Array [np .float64 ])
190
+ assert_type (np .trapezoid (AR_f8 , AR_f8 ), np .float64 | _nt .Array [np .float64 ])
191
+ assert_type (np .trapezoid (AR_i8 , AR_f8 ), np .float64 | _nt .Array [np .float64 ])
192
+ assert_type (np .trapezoid (AR_f8 , AR_i8 ), np .float64 | _nt .Array [np .float64 ])
193
+ assert_type (np .trapezoid (AR_c16 ), np .complex128 | _nt .Array [np .complex128 ])
194
+ assert_type (np .trapezoid (AR_c16 , AR_c16 ), np .complex128 | _nt .Array [np .complex128 ])
187
195
assert_type (np .trapezoid (AR_m ), np .timedelta64 | _nt .Array [np .timedelta64 ])
188
196
assert_type (np .trapezoid (AR_O ), Any )
189
- assert_type (np .trapezoid (AR_O , AR_LIKE_f8 ), Any )
197
+ assert_type (np .trapezoid (AR_O , AR_LIKE_f ), Any )
190
198
191
199
assert_type (np .meshgrid (), tuple [()])
192
200
assert_type (np .meshgrid (AR_c16 , indexing = "ij" ), tuple [_nt .Array1D [np .complex128 ]])
193
201
assert_type (np .meshgrid (AR_i8 , AR_f8 , copy = False ), tuple [_nt .Array2D [np .int64 ], _nt .Array2D [np .float64 ]])
194
- assert_type (np .meshgrid (AR_LIKE_f8 , AR_f8 ), tuple [_nt .Array2D , _nt .Array2D [np .float64 ]])
195
- assert_type (np .meshgrid (AR_LIKE_f8 , AR_i8 , AR_c16 ), tuple [_nt .Array3D , _nt .Array3D , _nt .Array3D ])
202
+ assert_type (np .meshgrid (AR_LIKE_f , AR_f8 ), tuple [_nt .Array2D , _nt .Array2D [np .float64 ]])
203
+ assert_type (np .meshgrid (AR_LIKE_f , AR_i8 , AR_c16 ), tuple [_nt .Array3D , _nt .Array3D , _nt .Array3D ])
196
204
assert_type (np .meshgrid (AR_f8 , AR_f8 , AR_f8 , AR_f8 ), tuple [_nt .Array4D , _nt .Array4D , _nt .Array4D , _nt .Array4D ])
197
- assert_type (np .meshgrid (* AR_LIKE_f8 ), tuple [_nt .Array [Any ], ...])
205
+ assert_type (np .meshgrid (* AR_LIKE_f ), tuple [_nt .Array [Any ], ...])
198
206
199
207
assert_type (np .delete (AR_f8 , np .s_ [:5 ]), _nt .Array [np .float64 ])
200
- assert_type (np .delete (AR_LIKE_f8 , [0 , 4 , 9 ], axis = 0 ), _nt .Array [Any ])
208
+ assert_type (np .delete (AR_LIKE_f , [0 , 4 , 9 ], axis = 0 ), _nt .Array [Any ])
201
209
202
210
assert_type (np .insert (AR_f8 , np .s_ [:5 ], 5 ), _nt .Array [np .float64 ])
203
- assert_type (np .insert (AR_LIKE_f8 , [0 , 4 , 9 ], [0.5 , 9.2 , 7 ], axis = 0 ), _nt .Array [Any ])
211
+ assert_type (np .insert (AR_LIKE_f , [0 , 4 , 9 ], [0.5 , 9.2 , 7 ], axis = 0 ), _nt .Array [Any ])
204
212
205
213
assert_type (np .append (AR_f8 , 5 ), _nt .Array [Any ])
206
- assert_type (np .append (AR_LIKE_f8 , 1j , axis = 0 ), _nt .Array [Any ])
214
+ assert_type (np .append (AR_LIKE_f , 1j , axis = 0 ), _nt .Array [Any ])
207
215
208
216
assert_type (np .digitize (4.5 , [1 ]), np .intp )
209
217
assert_type (np .digitize (AR_f8 , [1 , 2 , 3 ]), _nt .Array [np .intp ])
0 commit comments