Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions dpnp/tests/test_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,9 +1067,7 @@ def test_seed(self):

class TestPermutationsTestShuffle:
@pytest.mark.parametrize(
"dtype",
[dpnp.float32, dpnp.float64, dpnp.int32, dpnp.int64],
ids=["float32", "float64", "int32", "int64"],
"dtype", [dpnp.float32, dpnp.float64, dpnp.int32, dpnp.int64]
)
def test_shuffle(self, dtype):
seed = 28041990
Expand All @@ -1086,9 +1084,7 @@ def test_shuffle(self, dtype):
assert_array_equal(actual_x, desired_x)

@pytest.mark.parametrize(
"dtype",
[dpnp.float32, dpnp.float64, dpnp.int32, dpnp.int64],
ids=["float32", "float64", "int32", "int64"],
"dtype", [dpnp.float32, dpnp.float64, dpnp.int32, dpnp.int64]
)
def test_no_miss_numbers(self, dtype):
seed = 28041990
Expand Down
87 changes: 18 additions & 69 deletions dpnp/tests/test_random_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,8 @@ def get_default_floating():


class TestNormal:
@pytest.mark.parametrize(
"dtype",
[dpnp.float32, dpnp.float64, None],
ids=["float32", "float64", "None"],
)
@pytest.mark.parametrize(
"usm_type",
["host", "device", "shared"],
ids=["host", "device", "shared"],
)
@pytest.mark.parametrize("dtype", [dpnp.float32, dpnp.float64, None])
@pytest.mark.parametrize("usm_type", ["host", "device", "shared"])
def test_distr(self, dtype, usm_type):
seed = 1234567
sycl_queue = dpctl.SyclQueue()
Expand Down Expand Up @@ -98,16 +90,8 @@ def test_distr(self, dtype, usm_type):
# check if compute follows data isn't broken
assert_cfd(dpnp_data, sycl_queue, usm_type)

@pytest.mark.parametrize(
"dtype",
[dpnp.float32, dpnp.float64, None],
ids=["float32", "float64", "None"],
)
@pytest.mark.parametrize(
"usm_type",
["host", "device", "shared"],
ids=["host", "device", "shared"],
)
@pytest.mark.parametrize("dtype", [dpnp.float32, dpnp.float64, None])
@pytest.mark.parametrize("usm_type", ["host", "device", "shared"])
def test_scale(self, dtype, usm_type):
mean = 7
rs = RandomState(39567)
Expand Down Expand Up @@ -150,14 +134,12 @@ def test_inf_loc(self, loc):

def test_inf_scale(self):
a = RandomState().normal(0, numpy.inf, size=1000)
assert_equal(dpnp.isnan(a).any(), False)
assert_equal(dpnp.isinf(a).all(), True)
assert not dpnp.isnan(a).any()
assert dpnp.isinf(a).all()
assert_equal(a.max(), numpy.inf)
assert_equal(a.min(), -numpy.inf)

@pytest.mark.parametrize(
"loc", [numpy.inf, -numpy.inf], ids=["numpy.inf", "-numpy.inf"]
)
@pytest.mark.parametrize("loc", [numpy.inf, -numpy.inf])
def test_inf_loc_scale(self, loc):
a = RandomState().normal(loc=loc, scale=numpy.inf, size=1000)
assert_equal(dpnp.isnan(a).all(), False)
Expand Down Expand Up @@ -270,11 +252,7 @@ def test_invalid_usm_type(self, usm_type):


class TestRand:
@pytest.mark.parametrize(
"usm_type",
["host", "device", "shared"],
ids=["host", "device", "shared"],
)
@pytest.mark.parametrize("usm_type", ["host", "device", "shared"])
def test_distr(self, usm_type):
seed = 28042
sycl_queue = dpctl.SyclQueue()
Expand Down Expand Up @@ -359,11 +337,7 @@ class TestRandInt:
[int, dpnp.int32, dpnp.int_],
ids=["int", "dpnp.int32", "dpnp.int_"],
)
@pytest.mark.parametrize(
"usm_type",
["host", "device", "shared"],
ids=["host", "device", "shared"],
)
@pytest.mark.parametrize("usm_type", ["host", "device", "shared"])
def test_distr(self, dtype, usm_type):
seed = 9864
low = 1
Expand Down Expand Up @@ -593,11 +567,7 @@ def test_invalid_usm_type(self, usm_type):


class TestRandN:
@pytest.mark.parametrize(
"usm_type",
["host", "device", "shared"],
ids=["host", "device", "shared"],
)
@pytest.mark.parametrize("usm_type", ["host", "device", "shared"])
def test_distr(self, usm_type):
seed = 3649
sycl_queue = dpctl.SyclQueue()
Expand Down Expand Up @@ -627,6 +597,7 @@ def test_distr(self, usm_type):

# TODO: discuss with oneMKL: there is a difference between CPU and GPU
# generated samples since 9 digit while precision=15 for float64
# precision = dpnp.finfo(numpy.float64).precision
precision = dpnp.finfo(numpy.float32).precision
assert_array_almost_equal(data, expected, decimal=precision)

Expand Down Expand Up @@ -677,9 +648,7 @@ def test_wrong_dims(self):

class TestSeed:
@pytest.mark.parametrize(
"func",
["normal", "standard_normal", "random_sample", "uniform"],
ids=["normal", "standard_normal", "random_sample", "uniform"],
"func", ["normal", "standard_normal", "random_sample", "uniform"]
)
def test_scalar(self, func):
seed = 28041997
Expand Down Expand Up @@ -827,11 +796,7 @@ def test_invalid_shape(self, seed):


class TestStandardNormal:
@pytest.mark.parametrize(
"usm_type",
["host", "device", "shared"],
ids=["host", "device", "shared"],
)
@pytest.mark.parametrize("usm_type", ["host", "device", "shared"])
def test_distr(self, usm_type):
seed = 1234567
sycl_queue = dpctl.SyclQueue()
Expand Down Expand Up @@ -905,11 +870,7 @@ def test_wrong_dims(self):


class TestRandSample:
@pytest.mark.parametrize(
"usm_type",
["host", "device", "shared"],
ids=["host", "device", "shared"],
)
@pytest.mark.parametrize("usm_type", ["host", "device", "shared"])
def test_distr(self, usm_type):
seed = 12657
sycl_queue = dpctl.SyclQueue()
Expand Down Expand Up @@ -981,15 +942,9 @@ class TestUniform:
ids=["(low, high)=[1.23, 10.54]", "(low, high)=[10.54, 1.23]"],
)
@pytest.mark.parametrize(
"dtype",
[dpnp.float32, dpnp.float64, dpnp.int32, None],
ids=["float32", "float64", "int32", "None"],
)
@pytest.mark.parametrize(
"usm_type",
["host", "device", "shared"],
ids=["host", "device", "shared"],
"dtype", [dpnp.float32, dpnp.float64, dpnp.int32, None]
)
@pytest.mark.parametrize("usm_type", ["host", "device", "shared"])
def test_distr(self, bounds, dtype, usm_type):
seed = 28041997
low = bounds[0]
Expand Down Expand Up @@ -1043,15 +998,9 @@ def test_distr(self, bounds, dtype, usm_type):
assert_cfd(actual, sycl_queue, usm_type)

@pytest.mark.parametrize(
"dtype",
[dpnp.float32, dpnp.float64, dpnp.int32, None],
ids=["float32", "float64", "int32", "None"],
)
@pytest.mark.parametrize(
"usm_type",
["host", "device", "shared"],
ids=["host", "device", "shared"],
"dtype", [dpnp.float32, dpnp.float64, dpnp.int32, None]
)
@pytest.mark.parametrize("usm_type", ["host", "device", "shared"])
def test_low_high_equal(self, dtype, usm_type):
seed = 28045
low = high = 3.75
Expand Down
Loading