9
9
10
10
11
11
class TestDot :
12
+ @pytest .fixture
13
+ def gen_seed (self ):
14
+ numpy .random .seed (42 )
15
+
12
16
@pytest .mark .parametrize ("dtype" , get_all_dtypes ())
13
17
def test_dot_ones (self , dtype ):
14
18
n = 10 ** 5
@@ -35,7 +39,7 @@ def test_dot_arange(self, dtype):
35
39
assert_dtype_allclose (result , expected )
36
40
37
41
@pytest .mark .parametrize ("dtype" , get_all_dtypes ())
38
- def test_dot_scalar (self , dtype ):
42
+ def test_dot_scalar (self , dtype , gen_seed ):
39
43
a = 2
40
44
b = numpy .array (numpy .random .uniform (- 5 , 5 , 10 ), dtype = dtype )
41
45
ib = dpnp .array (b )
@@ -70,7 +74,7 @@ def test_dot_scalar(self, dtype):
70
74
"3d_3d" ,
71
75
],
72
76
)
73
- def test_dot (self , dtype , array_info ):
77
+ def test_dot (self , dtype , array_info , gen_seed ):
74
78
size1 , size2 , shape1 , shape2 = array_info
75
79
a = numpy .array (
76
80
numpy .random .uniform (- 5 , 5 , size1 ), dtype = dtype
@@ -111,7 +115,7 @@ def test_dot(self, dtype, array_info):
111
115
"3d_3d" ,
112
116
],
113
117
)
114
- def test_dot_complex (self , dtype , array_info ):
118
+ def test_dot_complex (self , dtype , array_info , gen_seed ):
115
119
size1 , size2 , shape1 , shape2 = array_info
116
120
x11 = numpy .random .uniform (- 5 , 5 , size1 )
117
121
x12 = numpy .random .uniform (- 5 , 5 , size1 )
@@ -152,7 +156,7 @@ def test_dot_complex(self, dtype, array_info):
152
156
"3d_3d" ,
153
157
],
154
158
)
155
- def test_dot_ndarray (self , dtype , array_info ):
159
+ def test_dot_ndarray (self , dtype , array_info , gen_seed ):
156
160
size1 , size2 , shape1 , shape2 = array_info
157
161
a = numpy .array (
158
162
numpy .random .uniform (- 5 , 5 , size1 ), dtype = dtype
@@ -191,7 +195,7 @@ def test_dot_strided(self, dtype):
191
195
assert_dtype_allclose (result , expected )
192
196
193
197
@pytest .mark .parametrize ("dtype" , get_all_dtypes (no_bool = True ))
194
- def test_dot_out_scalar (self , dtype ):
198
+ def test_dot_out_scalar (self , dtype , gen_seed ):
195
199
size = 10
196
200
a = 2
197
201
b = numpy .array (numpy .random .uniform (- 5 , 5 , size ), dtype = dtype )
@@ -231,7 +235,7 @@ def test_dot_out_scalar(self, dtype):
231
235
"3d_3d" ,
232
236
],
233
237
)
234
- def test_dot_out (self , dtype , array_info ):
238
+ def test_dot_out (self , dtype , array_info , gen_seed ):
235
239
size1 , size2 , shape1 , shape2 , out_shape = array_info
236
240
a = numpy .array (
237
241
numpy .random .uniform (- 5 , 5 , size1 ), dtype = dtype
@@ -251,7 +255,7 @@ def test_dot_out(self, dtype, array_info):
251
255
252
256
@pytest .mark .parametrize ("dtype1" , get_all_dtypes ())
253
257
@pytest .mark .parametrize ("dtype2" , get_all_dtypes ())
254
- def test_dot_input_dtype_matrix (self , dtype1 , dtype2 ):
258
+ def test_dot_input_dtype_matrix (self , dtype1 , dtype2 , gen_seed ):
255
259
a = numpy .array (numpy .random .uniform (- 5 , 5 , 10 ), dtype = dtype1 )
256
260
b = numpy .array (numpy .random .uniform (- 5 , 5 , 10 ), dtype = dtype2 )
257
261
ia = dpnp .array (a )
@@ -355,8 +359,12 @@ def test_multi_dot(type):
355
359
356
360
357
361
class TestTensordot :
362
+ @pytest .fixture
363
+ def gen_seed (self ):
364
+ numpy .random .seed (87 )
365
+
358
366
@pytest .mark .parametrize ("dtype" , get_all_dtypes ())
359
- def test_tensordot_scalar (self , dtype ):
367
+ def test_tensordot_scalar (self , dtype , gen_seed ):
360
368
a = 2
361
369
b = numpy .array (numpy .random .uniform (- 5 , 5 , 10 ), dtype = dtype )
362
370
ib = dpnp .array (b )
@@ -371,7 +379,7 @@ def test_tensordot_scalar(self, dtype):
371
379
372
380
@pytest .mark .parametrize ("dtype" , get_all_dtypes (no_complex = True ))
373
381
@pytest .mark .parametrize ("axes" , [- 3 , - 2 , - 1 , 0 , 1 , 2 ])
374
- def test_tensordot (self , dtype , axes ):
382
+ def test_tensordot (self , dtype , axes , gen_seed ):
375
383
a = numpy .array (numpy .random .uniform (- 10 , 10 , 64 ), dtype = dtype ).reshape (
376
384
4 , 4 , 4
377
385
)
@@ -383,12 +391,11 @@ def test_tensordot(self, dtype, axes):
383
391
384
392
result = dpnp .tensordot (ia , ib , axes = axes )
385
393
expected = numpy .tensordot (a , b , axes = axes )
386
- # TODO: investigate the effect of factor, see SAT-6700
387
- assert_dtype_allclose (result , expected , factor = 24 )
394
+ assert_dtype_allclose (result , expected )
388
395
389
396
@pytest .mark .parametrize ("dtype" , get_complex_dtypes ())
390
397
@pytest .mark .parametrize ("axes" , [- 3 , - 2 , - 1 , 0 , 1 , 2 ])
391
- def test_tensordot_complex (self , dtype , axes ):
398
+ def test_tensordot_complex (self , dtype , axes , gen_seed ):
392
399
x11 = numpy .random .uniform (- 10 , 10 , 64 )
393
400
x12 = numpy .random .uniform (- 10 , 10 , 64 )
394
401
x21 = numpy .random .uniform (- 10 , 10 , 64 )
@@ -400,8 +407,7 @@ def test_tensordot_complex(self, dtype, axes):
400
407
401
408
result = dpnp .tensordot (ia , ib , axes = axes )
402
409
expected = numpy .tensordot (a , b , axes = axes )
403
- # TODO: investigate the effect of factor, see SAT-6700
404
- assert_dtype_allclose (result , expected , factor = 24 )
410
+ assert_dtype_allclose (result , expected )
405
411
406
412
@pytest .mark .parametrize ("dtype" , get_all_dtypes (no_bool = True ))
407
413
@pytest .mark .parametrize (
@@ -414,7 +420,7 @@ def test_tensordot_complex(self, dtype, axes):
414
420
((3 , 1 ), (0 , 2 )),
415
421
],
416
422
)
417
- def test_tensordot_axes (self , dtype , axes ):
423
+ def test_tensordot_axes (self , dtype , axes , gen_seed ):
418
424
a = numpy .array (
419
425
numpy .random .uniform (- 10 , 10 , 120 ), dtype = dtype
420
426
).reshape (2 , 5 , 3 , 4 )
@@ -426,12 +432,11 @@ def test_tensordot_axes(self, dtype, axes):
426
432
427
433
result = dpnp .tensordot (ia , ib , axes = axes )
428
434
expected = numpy .tensordot (a , b , axes = axes )
429
- # TODO: investigate the effect of factor, see SAT-6700
430
- assert_dtype_allclose (result , expected , factor = 24 )
435
+ assert_dtype_allclose (result , expected )
431
436
432
437
@pytest .mark .parametrize ("dtype1" , get_all_dtypes ())
433
438
@pytest .mark .parametrize ("dtype2" , get_all_dtypes ())
434
- def test_tensordot_input_dtype_matrix (self , dtype1 , dtype2 ):
439
+ def test_tensordot_input_dtype_matrix (self , dtype1 , dtype2 , gen_seed ):
435
440
a = numpy .array (
436
441
numpy .random .uniform (- 10 , 10 , 60 ), dtype = dtype1
437
442
).reshape (3 , 4 , 5 )
@@ -443,10 +448,9 @@ def test_tensordot_input_dtype_matrix(self, dtype1, dtype2):
443
448
444
449
result = dpnp .tensordot (ia , ib )
445
450
expected = numpy .tensordot (a , b )
446
- # TODO: investigate the effect of factor, see SAT-6700
447
- assert_dtype_allclose (result , expected , factor = 24 )
451
+ assert_dtype_allclose (result , expected )
448
452
449
- def test_tensordot_strided (self ):
453
+ def test_tensordot_strided (self , gen_seed ):
450
454
for dim in [1 , 2 , 3 , 4 ]:
451
455
axes = 1 if dim == 1 else 2
452
456
A = numpy .random .rand (* ([10 ] * dim ))
@@ -500,6 +504,10 @@ def test_tensordot_error(self):
500
504
501
505
502
506
class TestVdot :
507
+ @pytest .fixture
508
+ def gen_seed (self ):
509
+ numpy .random .seed (42 )
510
+
503
511
@pytest .mark .parametrize ("dtype" , get_all_dtypes ())
504
512
def test_vdot_scalar (self , dtype ):
505
513
a = numpy .array ([3.5 ], dtype = dtype )
@@ -536,7 +544,7 @@ def test_vdot_scalar(self, dtype):
536
544
"3d_3d" ,
537
545
],
538
546
)
539
- def test_vdot (self , dtype , array_info ):
547
+ def test_vdot (self , dtype , array_info , gen_seed ):
540
548
size1 , size2 , shape1 , shape2 = array_info
541
549
a = numpy .array (
542
550
numpy .random .uniform (- 5 , 5 , size1 ), dtype = dtype
@@ -573,7 +581,7 @@ def test_vdot(self, dtype, array_info):
573
581
"3d_3d" ,
574
582
],
575
583
)
576
- def test_vdot_complex (self , dtype , array_info ):
584
+ def test_vdot_complex (self , dtype , array_info , gen_seed ):
577
585
size1 , size2 , shape1 , shape2 = array_info
578
586
x11 = numpy .random .uniform (- 5 , 5 , size1 )
579
587
x12 = numpy .random .uniform (- 5 , 5 , size1 )
@@ -613,7 +621,7 @@ def test_vdot_strided(self, dtype):
613
621
614
622
@pytest .mark .parametrize ("dtype1" , get_all_dtypes ())
615
623
@pytest .mark .parametrize ("dtype2" , get_all_dtypes ())
616
- def test_vdot_input_dtype_matrix (self , dtype1 , dtype2 ):
624
+ def test_vdot_input_dtype_matrix (self , dtype1 , dtype2 , gen_seed ):
617
625
a = numpy .array (numpy .random .uniform (- 5 , 5 , 10 ), dtype = dtype1 )
618
626
b = numpy .array (numpy .random .uniform (- 5 , 5 , 10 ), dtype = dtype2 )
619
627
ia = dpnp .array (a )
0 commit comments