Skip to content

Commit f33ef19

Browse files
authored
use a seed for random input numbers in tests (#1716)
* add gen_seed change seed * use setup_method * remove duplicates
1 parent 3461932 commit f33ef19

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

tests/test_dot.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010

1111
class TestDot:
12+
def setup_method(self):
13+
numpy.random.seed(42)
14+
1215
@pytest.mark.parametrize("dtype", get_all_dtypes())
1316
def test_dot_ones(self, dtype):
1417
n = 10**5
@@ -355,6 +358,9 @@ def test_multi_dot(type):
355358

356359

357360
class TestTensordot:
361+
def setup_method(self):
362+
numpy.random.seed(87)
363+
358364
@pytest.mark.parametrize("dtype", get_all_dtypes())
359365
def test_tensordot_scalar(self, dtype):
360366
a = 2
@@ -383,8 +389,7 @@ def test_tensordot(self, dtype, axes):
383389

384390
result = dpnp.tensordot(ia, ib, axes=axes)
385391
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)
392+
assert_dtype_allclose(result, expected)
388393

389394
@pytest.mark.parametrize("dtype", get_complex_dtypes())
390395
@pytest.mark.parametrize("axes", [-3, -2, -1, 0, 1, 2])
@@ -400,8 +405,7 @@ def test_tensordot_complex(self, dtype, axes):
400405

401406
result = dpnp.tensordot(ia, ib, axes=axes)
402407
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)
408+
assert_dtype_allclose(result, expected)
405409

406410
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True))
407411
@pytest.mark.parametrize(
@@ -426,8 +430,7 @@ def test_tensordot_axes(self, dtype, axes):
426430

427431
result = dpnp.tensordot(ia, ib, axes=axes)
428432
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)
433+
assert_dtype_allclose(result, expected)
431434

432435
@pytest.mark.parametrize("dtype1", get_all_dtypes())
433436
@pytest.mark.parametrize("dtype2", get_all_dtypes())
@@ -443,8 +446,7 @@ def test_tensordot_input_dtype_matrix(self, dtype1, dtype2):
443446

444447
result = dpnp.tensordot(ia, ib)
445448
expected = numpy.tensordot(a, b)
446-
# TODO: investigate the effect of factor, see SAT-6700
447-
assert_dtype_allclose(result, expected, factor=24)
449+
assert_dtype_allclose(result, expected)
448450

449451
def test_tensordot_strided(self):
450452
for dim in [1, 2, 3, 4]:
@@ -500,6 +502,9 @@ def test_tensordot_error(self):
500502

501503

502504
class TestVdot:
505+
def setup_method(self):
506+
numpy.random.seed(42)
507+
503508
@pytest.mark.parametrize("dtype", get_all_dtypes())
504509
def test_vdot_scalar(self, dtype):
505510
a = numpy.array([3.5], dtype=dtype)

tests/test_mathematical.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,6 +2486,9 @@ def test_inplace_floor_divide(dtype):
24862486

24872487

24882488
class TestMatmul:
2489+
def setup_method(self):
2490+
numpy.random.seed(42)
2491+
24892492
@pytest.mark.parametrize(
24902493
"order_pair", [("C", "C"), ("C", "F"), ("F", "C"), ("F", "F")]
24912494
)
@@ -2655,8 +2658,7 @@ def test_matmul_axes_ND_ND(self, dtype, axes):
26552658

26562659
result = dpnp.matmul(ia, ib, axes=axes)
26572660
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)
2661+
assert_dtype_allclose(result, expected)
26602662

26612663
@pytest.mark.parametrize(
26622664
"axes",
@@ -2726,8 +2728,7 @@ def test_matmul_axes_out(self, dtype, axes, out_shape):
27262728
result = dpnp.matmul(ia, ib, axes=axes, out=out_dp)
27272729
assert result is out_dp
27282730
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)
2731+
assert_dtype_allclose(result, expected)
27312732

27322733
@pytest.mark.parametrize(
27332734
"axes, b_shape, out_shape",

0 commit comments

Comments
 (0)