20
20
@given (hh .mutually_promotable_dtypes (None ))
21
21
def test_result_type (dtypes ):
22
22
out = xp .result_type (* dtypes )
23
- ph .assert_dtype (
24
- f'result_type({ dh .fmt_types (dtypes )} )' , 'out' , out , dh .result_type (* dtypes )
25
- )
23
+ ph .assert_dtype ('result_type' , dtypes , 'out' , out , dh .result_type (* dtypes ))
26
24
27
25
28
26
@given (
@@ -37,9 +35,8 @@ def test_meshgrid(dtypes, data):
37
35
arrays .append (x )
38
36
out = xp .meshgrid (* arrays )
39
37
expected = dh .result_type (* dtypes )
40
- test_case = f'meshgrid({ dh .fmt_types (dtypes )} )'
41
38
for i , x in enumerate (out ):
42
- ph .assert_dtype (test_case , f'out[{ i } ].dtype' , x .dtype , expected )
39
+ ph .assert_dtype ('meshgrid' , dtypes , f'out[{ i } ].dtype' , x .dtype , expected )
43
40
44
41
45
42
@given (
@@ -53,12 +50,7 @@ def test_concat(shape, dtypes, data):
53
50
x = data .draw (xps .arrays (dtype = dtype , shape = shape ), label = f'x{ i } ' )
54
51
arrays .append (x )
55
52
out = xp .concat (arrays )
56
- ph .assert_dtype (
57
- f'concat({ dh .fmt_types (dtypes )} )' ,
58
- 'out.dtype' ,
59
- out .dtype ,
60
- dh .result_type (* dtypes ),
61
- )
53
+ ph .assert_dtype ('concat' , dtypes , 'out.dtype' , out .dtype , dh .result_type (* dtypes ))
62
54
63
55
64
56
@given (
@@ -72,12 +64,7 @@ def test_stack(shape, dtypes, data):
72
64
x = data .draw (xps .arrays (dtype = dtype , shape = shape ), label = f'x{ i } ' )
73
65
arrays .append (x )
74
66
out = xp .stack (arrays )
75
- ph .assert_dtype (
76
- f'stack({ dh .fmt_types (dtypes )} )' ,
77
- 'out.dtype' ,
78
- out .dtype ,
79
- dh .result_type (* dtypes ),
80
- )
67
+ ph .assert_dtype ('stack' , dtypes , 'out.dtype' , out .dtype , dh .result_type (* dtypes ))
81
68
82
69
83
70
bitwise_shift_funcs = [
@@ -163,9 +150,7 @@ def test_func_promotion(func_name, in_dtypes, out_dtype, data):
163
150
out = func (* arrays )
164
151
except OverflowError :
165
152
reject ()
166
- ph .assert_dtype (
167
- f'{ func_name } ({ dh .fmt_types (in_dtypes )} )' , 'out.dtype' , out .dtype , out_dtype
168
- )
153
+ ph .assert_dtype (func_name , in_dtypes , 'out.dtype' , out .dtype , out_dtype )
169
154
170
155
171
156
promotion_params : List [Param [Tuple [DataType , DataType ], DataType ]] = []
@@ -185,9 +170,7 @@ def test_where(in_dtypes, out_dtype, shapes, data):
185
170
x2 = data .draw (xps .arrays (dtype = in_dtypes [1 ], shape = shapes [1 ]), label = 'x2' )
186
171
cond = data .draw (xps .arrays (dtype = xp .bool , shape = shapes [2 ]), label = 'condition' )
187
172
out = xp .where (cond , x1 , x2 )
188
- ph .assert_dtype (
189
- f'where({ dh .fmt_types (in_dtypes )} )' , 'out.dtype' , out .dtype , out_dtype
190
- )
173
+ ph .assert_dtype ('where' , in_dtypes , 'out.dtype' , out .dtype , out_dtype )
191
174
192
175
193
176
numeric_promotion_params = promotion_params [1 :]
@@ -199,9 +182,7 @@ def test_tensordot(in_dtypes, out_dtype, shapes, data):
199
182
x1 = data .draw (xps .arrays (dtype = in_dtypes [0 ], shape = shapes [0 ]), label = 'x1' )
200
183
x2 = data .draw (xps .arrays (dtype = in_dtypes [1 ], shape = shapes [1 ]), label = 'x2' )
201
184
out = xp .tensordot (x1 , x2 )
202
- ph .assert_dtype (
203
- f'tensordot({ dh .fmt_types (in_dtypes )} )' , 'out.dtype' , out .dtype , out_dtype
204
- )
185
+ ph .assert_dtype ('tensordot' , in_dtypes , 'out.dtype' , out .dtype , out_dtype )
205
186
206
187
207
188
@pytest .mark .parametrize ('in_dtypes, out_dtype' , numeric_promotion_params )
@@ -210,9 +191,7 @@ def test_vecdot(in_dtypes, out_dtype, shapes, data):
210
191
x1 = data .draw (xps .arrays (dtype = in_dtypes [0 ], shape = shapes [0 ]), label = 'x1' )
211
192
x2 = data .draw (xps .arrays (dtype = in_dtypes [1 ], shape = shapes [1 ]), label = 'x2' )
212
193
out = xp .vecdot (x1 , x2 )
213
- ph .assert_dtype (
214
- f'vecdot({ dh .fmt_types (in_dtypes )} )' , 'out.dtype' , out .dtype , out_dtype
215
- )
194
+ ph .assert_dtype ('vecdot' , in_dtypes , 'out.dtype' , out .dtype , out_dtype )
216
195
217
196
218
197
op_params : List [Param [str , str , Tuple [DataType , ...], DataType ]] = []
@@ -280,9 +259,7 @@ def test_op_promotion(op, expr, in_dtypes, out_dtype, data):
280
259
out = eval (expr , locals_ )
281
260
except OverflowError :
282
261
reject ()
283
- ph .assert_dtype (
284
- f'{ op } ({ dh .fmt_types (in_dtypes )} )' , 'out.dtype' , out .dtype , out_dtype
285
- )
262
+ ph .assert_dtype (op , in_dtypes , 'out.dtype' , out .dtype , out_dtype )
286
263
287
264
288
265
inplace_params : List [Param [str , str , Tuple [DataType , ...], DataType ]] = []
@@ -323,7 +300,7 @@ def test_inplace_op_promotion(op, expr, in_dtypes, out_dtype, shapes, data):
323
300
except OverflowError :
324
301
reject ()
325
302
x1 = locals_ ['x1' ]
326
- ph .assert_dtype (f' { op } ( { dh . fmt_types ( in_dtypes ) } )' , 'x1.dtype' , x1 .dtype , out_dtype )
303
+ ph .assert_dtype (op , in_dtypes , 'x1.dtype' , x1 .dtype , out_dtype )
327
304
328
305
329
306
op_scalar_params : List [Param [str , str , DataType , ScalarType , DataType ]] = []
@@ -357,9 +334,7 @@ def test_op_scalar_promotion(op, expr, in_dtype, in_stype, out_dtype, data):
357
334
out = eval (expr , {'x' : x , 's' : s })
358
335
except OverflowError :
359
336
reject ()
360
- ph .assert_dtype (
361
- f'{ op } ({ dh .fmt_types ((in_dtype , in_stype ))} )' , 'out.dtype' , out .dtype , out_dtype
362
- )
337
+ ph .assert_dtype (op , (in_dtype , in_stype ), 'out.dtype' , out .dtype , out_dtype )
363
338
364
339
365
340
inplace_scalar_params : List [Param [str , str , DataType , ScalarType ]] = []
@@ -394,9 +369,7 @@ def test_inplace_op_scalar_promotion(op, expr, dtype, in_stype, data):
394
369
reject ()
395
370
x = locals_ ['x' ]
396
371
assert x .dtype == dtype , f'{ x .dtype = !s} , but should be { dtype } '
397
- ph .assert_dtype (
398
- f'{ op } ({ dh .fmt_types ((dtype , in_stype ))} )' , 'x.dtype' , x .dtype , dtype
399
- )
372
+ ph .assert_dtype (op , (dtype , in_stype ), 'x.dtype' , x .dtype , dtype )
400
373
401
374
402
375
if __name__ == '__main__' :
0 commit comments