Skip to content

Commit 1a0b1bb

Browse files
authored
Add seeding before generating random data in faulty tests (#2181)
* Add seeding before generating random data in faulty tests * Update test_rand_period
1 parent ad56443 commit 1a0b1bb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dpnp/tests/test_mathematical.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from .helper import (
2424
assert_dtype_allclose,
25+
generate_random_numpy_array,
2526
get_all_dtypes,
2627
get_complex_dtypes,
2728
get_float_complex_dtypes,
@@ -2321,7 +2322,7 @@ def test_basic(self, dt):
23212322
"dt", get_all_dtypes(no_none=True, no_complex=True)
23222323
)
23232324
def test_rand(self, dt):
2324-
a = numpy.random.rand(10) * 100
2325+
a = generate_random_numpy_array((10,), seed_value=42) * 100
23252326
a = a.astype(dtype=dt)
23262327
ia = dpnp.array(a)
23272328

@@ -2345,7 +2346,7 @@ def test_period(self, dt):
23452346
"dt", get_all_dtypes(no_none=True, no_bool=True, no_complex=True)
23462347
)
23472348
def test_rand_period(self, dt):
2348-
a = numpy.random.rand(10) * 1000
2349+
a = generate_random_numpy_array((10,), seed_value=42) * 1000
23492350
a = a.astype(dtype=dt)
23502351
ia = dpnp.array(a)
23512352

@@ -3429,6 +3430,7 @@ def test_basic(self, array, val, data_type, val_type):
34293430

34303431
@pytest.mark.parametrize("dtype", get_all_dtypes())
34313432
def test_power(self, dtype):
3433+
numpy.random.seed(42)
34323434
np_array1, np_array2, expected = _get_numpy_arrays_2in_1out(
34333435
"power", dtype, [0, 10, 10]
34343436
)

0 commit comments

Comments
 (0)