Skip to content

Commit 9d47b6a

Browse files
committed
add seed
1 parent ba7bed4 commit 9d47b6a

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

tests/test_dot.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def test_dot_arange(self, dtype):
3636

3737
@pytest.mark.parametrize("dtype", get_all_dtypes())
3838
def test_dot_scalar(self, dtype):
39+
numpy.random.seed(42)
3940
a = 2
4041
b = numpy.array(numpy.random.uniform(-5, 5, 10), dtype=dtype)
4142
ib = dpnp.array(b)
@@ -72,6 +73,7 @@ def test_dot_scalar(self, dtype):
7273
)
7374
def test_dot(self, dtype, array_info):
7475
size1, size2, shape1, shape2 = array_info
76+
numpy.random.seed(42)
7577
a = numpy.array(
7678
numpy.random.uniform(-5, 5, size1), dtype=dtype
7779
).reshape(shape1)
@@ -113,6 +115,7 @@ def test_dot(self, dtype, array_info):
113115
)
114116
def test_dot_complex(self, dtype, array_info):
115117
size1, size2, shape1, shape2 = array_info
118+
numpy.random.seed(42)
116119
x11 = numpy.random.uniform(-5, 5, size1)
117120
x12 = numpy.random.uniform(-5, 5, size1)
118121
x21 = numpy.random.uniform(-5, 5, size2)
@@ -154,6 +157,7 @@ def test_dot_complex(self, dtype, array_info):
154157
)
155158
def test_dot_ndarray(self, dtype, array_info):
156159
size1, size2, shape1, shape2 = array_info
160+
numpy.random.seed(42)
157161
a = numpy.array(
158162
numpy.random.uniform(-5, 5, size1), dtype=dtype
159163
).reshape(shape1)
@@ -194,6 +198,7 @@ def test_dot_strided(self, dtype):
194198
def test_dot_out_scalar(self, dtype):
195199
size = 10
196200
a = 2
201+
numpy.random.seed(42)
197202
b = numpy.array(numpy.random.uniform(-5, 5, size), dtype=dtype)
198203
ia = 2
199204
ib = dpnp.array(b)
@@ -233,6 +238,7 @@ def test_dot_out_scalar(self, dtype):
233238
)
234239
def test_dot_out(self, dtype, array_info):
235240
size1, size2, shape1, shape2, out_shape = array_info
241+
numpy.random.seed(42)
236242
a = numpy.array(
237243
numpy.random.uniform(-5, 5, size1), dtype=dtype
238244
).reshape(shape1)
@@ -252,6 +258,7 @@ def test_dot_out(self, dtype, array_info):
252258
@pytest.mark.parametrize("dtype1", get_all_dtypes())
253259
@pytest.mark.parametrize("dtype2", get_all_dtypes())
254260
def test_dot_input_dtype_matrix(self, dtype1, dtype2):
261+
numpy.random.seed(42)
255262
a = numpy.array(numpy.random.uniform(-5, 5, 10), dtype=dtype1)
256263
b = numpy.array(numpy.random.uniform(-5, 5, 10), dtype=dtype2)
257264
ia = dpnp.array(a)
@@ -358,6 +365,7 @@ class TestTensordot:
358365
@pytest.mark.parametrize("dtype", get_all_dtypes())
359366
def test_tensordot_scalar(self, dtype):
360367
a = 2
368+
numpy.random.seed(42)
361369
b = numpy.array(numpy.random.uniform(-5, 5, 10), dtype=dtype)
362370
ib = dpnp.array(b)
363371

@@ -372,6 +380,7 @@ def test_tensordot_scalar(self, dtype):
372380
@pytest.mark.parametrize("dtype", get_all_dtypes(no_complex=True))
373381
@pytest.mark.parametrize("axes", [-3, -2, -1, 0, 1, 2])
374382
def test_tensordot(self, dtype, axes):
383+
numpy.random.seed(42)
375384
a = numpy.array(numpy.random.uniform(-10, 10, 64), dtype=dtype).reshape(
376385
4, 4, 4
377386
)
@@ -383,12 +392,12 @@ def test_tensordot(self, dtype, axes):
383392

384393
result = dpnp.tensordot(ia, ib, axes=axes)
385394
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)
395+
assert_dtype_allclose(result, expected)
388396

389397
@pytest.mark.parametrize("dtype", get_complex_dtypes())
390398
@pytest.mark.parametrize("axes", [-3, -2, -1, 0, 1, 2])
391399
def test_tensordot_complex(self, dtype, axes):
400+
numpy.random.seed(42)
392401
x11 = numpy.random.uniform(-10, 10, 64)
393402
x12 = numpy.random.uniform(-10, 10, 64)
394403
x21 = numpy.random.uniform(-10, 10, 64)
@@ -400,8 +409,7 @@ def test_tensordot_complex(self, dtype, axes):
400409

401410
result = dpnp.tensordot(ia, ib, axes=axes)
402411
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)
412+
assert_dtype_allclose(result, expected)
405413

406414
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True))
407415
@pytest.mark.parametrize(
@@ -415,6 +423,7 @@ def test_tensordot_complex(self, dtype, axes):
415423
],
416424
)
417425
def test_tensordot_axes(self, dtype, axes):
426+
numpy.random.seed(42)
418427
a = numpy.array(
419428
numpy.random.uniform(-10, 10, 120), dtype=dtype
420429
).reshape(2, 5, 3, 4)
@@ -426,12 +435,12 @@ def test_tensordot_axes(self, dtype, axes):
426435

427436
result = dpnp.tensordot(ia, ib, axes=axes)
428437
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)
438+
assert_dtype_allclose(result, expected)
431439

432440
@pytest.mark.parametrize("dtype1", get_all_dtypes())
433441
@pytest.mark.parametrize("dtype2", get_all_dtypes())
434442
def test_tensordot_input_dtype_matrix(self, dtype1, dtype2):
443+
numpy.random.seed(42)
435444
a = numpy.array(
436445
numpy.random.uniform(-10, 10, 60), dtype=dtype1
437446
).reshape(3, 4, 5)
@@ -443,10 +452,10 @@ def test_tensordot_input_dtype_matrix(self, dtype1, dtype2):
443452

444453
result = dpnp.tensordot(ia, ib)
445454
expected = numpy.tensordot(a, b)
446-
# TODO: investigate the effect of factor, see SAT-6700
447-
assert_dtype_allclose(result, expected, factor=24)
455+
assert_dtype_allclose(result, expected)
448456

449457
def test_tensordot_strided(self):
458+
numpy.random.seed(42)
450459
for dim in [1, 2, 3, 4]:
451460
axes = 1 if dim == 1 else 2
452461
A = numpy.random.rand(*([10] * dim))
@@ -538,6 +547,7 @@ def test_vdot_scalar(self, dtype):
538547
)
539548
def test_vdot(self, dtype, array_info):
540549
size1, size2, shape1, shape2 = array_info
550+
numpy.random.seed(42)
541551
a = numpy.array(
542552
numpy.random.uniform(-5, 5, size1), dtype=dtype
543553
).reshape(shape1)
@@ -575,6 +585,7 @@ def test_vdot(self, dtype, array_info):
575585
)
576586
def test_vdot_complex(self, dtype, array_info):
577587
size1, size2, shape1, shape2 = array_info
588+
numpy.random.seed(42)
578589
x11 = numpy.random.uniform(-5, 5, size1)
579590
x12 = numpy.random.uniform(-5, 5, size1)
580591
x21 = numpy.random.uniform(-5, 5, size2)
@@ -614,6 +625,7 @@ def test_vdot_strided(self, dtype):
614625
@pytest.mark.parametrize("dtype1", get_all_dtypes())
615626
@pytest.mark.parametrize("dtype2", get_all_dtypes())
616627
def test_vdot_input_dtype_matrix(self, dtype1, dtype2):
628+
numpy.random.seed(42)
617629
a = numpy.array(numpy.random.uniform(-5, 5, 10), dtype=dtype1)
618630
b = numpy.array(numpy.random.uniform(-5, 5, 10), dtype=dtype2)
619631
ia = dpnp.array(a)

tests/test_mathematical.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,6 +2644,7 @@ def test_matmul_dtype(self, dtype, shape_pair):
26442644
],
26452645
)
26462646
def test_matmul_axes_ND_ND(self, dtype, axes):
2647+
numpy.random.seed(42)
26472648
a = numpy.array(
26482649
numpy.random.uniform(-10, 10, 120), dtype=dtype
26492650
).reshape(2, 5, 3, 4)
@@ -2655,8 +2656,7 @@ def test_matmul_axes_ND_ND(self, dtype, axes):
26552656

26562657
result = dpnp.matmul(ia, ib, axes=axes)
26572658
expected = numpy.matmul(a, b, axes=axes)
2658-
# TODO: investigate the effect of factor, see SAT-6700
2659-
assert_dtype_allclose(result, expected, factor=24)
2659+
assert_dtype_allclose(result, expected)
26602660

26612661
@pytest.mark.parametrize(
26622662
"axes",
@@ -2713,6 +2713,7 @@ def test_matmul_axes_1D_1D(self):
27132713
],
27142714
)
27152715
def test_matmul_axes_out(self, dtype, axes, out_shape):
2716+
numpy.random.seed(42)
27162717
a = numpy.array(
27172718
numpy.random.uniform(-10, 10, 120), dtype=dtype
27182719
).reshape(2, 5, 3, 4)
@@ -2726,8 +2727,7 @@ def test_matmul_axes_out(self, dtype, axes, out_shape):
27262727
result = dpnp.matmul(ia, ib, axes=axes, out=out_dp)
27272728
assert result is out_dp
27282729
expected = numpy.matmul(a, b, axes=axes)
2729-
# TODO: investigate the effect of factor, see SAT-6700
2730-
assert_dtype_allclose(result, expected, factor=24)
2730+
assert_dtype_allclose(result, expected)
27312731

27322732
@pytest.mark.parametrize(
27332733
"axes, b_shape, out_shape",
@@ -2841,6 +2841,7 @@ def test_matmul_order(self, order, shape_pair):
28412841
assert_dtype_allclose(result, expected)
28422842

28432843
def test_matmul_strided(self):
2844+
numpy.random.seed(42)
28442845
for dim in [1, 2, 3, 4]:
28452846
A = numpy.random.rand(*([20] * dim))
28462847
B = dpnp.asarray(A)

0 commit comments

Comments
 (0)