Skip to content

Commit f3fa90a

Browse files
authored
Merge fde1902 into 367e74e
2 parents 367e74e + fde1902 commit f3fa90a

25 files changed

+3674
-947
lines changed

dpnp/tests/skipped_tests.tbl

Lines changed: 0 additions & 214 deletions
Large diffs are not rendered by default.

dpnp/tests/skipped_tests_gpu.tbl

Lines changed: 0 additions & 215 deletions
Large diffs are not rendered by default.

dpnp/tests/skipped_tests_gpu_no_fp64.tbl

Lines changed: 0 additions & 171 deletions
Large diffs are not rendered by default.

dpnp/tests/third_party/cupy/random_tests/common_distributions.py

Lines changed: 517 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import unittest
2+
3+
import numpy
4+
import pytest
5+
6+
import dpnp as cupy
7+
from dpnp import random
8+
from dpnp.tests.third_party.cupy import testing
9+
10+
pytest.skip("bit generator is not supported yet", allow_module_level=True)
11+
12+
13+
class BitGeneratorTestCase:
14+
15+
def setUp(self):
16+
self.seed = testing.generate_seed()
17+
18+
def check_seed(self, seed):
19+
bg1 = self.bg(seed)
20+
bg2 = self.bg(seed)
21+
bg3 = self.bg(None)
22+
23+
xs1 = bg1.random_raw(10)
24+
xs2 = bg2.random_raw(10)
25+
xs3 = bg3.random_raw(10)
26+
27+
# Random state must be reproducible
28+
assert cupy.array_equal(xs1, xs2)
29+
# Random state must be initialized randomly with seed=None
30+
assert not cupy.array_equal(xs1, xs3)
31+
32+
@testing.for_int_dtypes(no_bool=True)
33+
def test_seed_not_none(self, dtype):
34+
self.check_seed(dtype(0))
35+
36+
@testing.for_dtypes([numpy.complex128])
37+
def test_seed_invalid_type_complex(self, dtype):
38+
with self.assertRaises(TypeError):
39+
self.bg(dtype(0))
40+
41+
@testing.for_float_dtypes()
42+
def test_seed_invalid_type_float(self, dtype):
43+
with self.assertRaises(TypeError):
44+
self.bg(dtype(0))
45+
46+
def test_array_seed(self):
47+
self.check_seed(numpy.random.randint(0, 2**31, size=10))
48+
49+
50+
@testing.with_requires("numpy>=1.17.0")
51+
@testing.fix_random()
52+
@pytest.mark.skipif(
53+
cupy.cuda.runtime.is_hip, reason="HIP does not support this"
54+
)
55+
class TestBitGeneratorXORWOW(BitGeneratorTestCase, unittest.TestCase):
56+
def setUp(self):
57+
super().setUp()
58+
self.bg = random._bit_generator.XORWOW
59+
60+
61+
@testing.with_requires("numpy>=1.17.0")
62+
@testing.fix_random()
63+
@pytest.mark.skipif(
64+
cupy.cuda.runtime.is_hip, reason="HIP does not support this"
65+
)
66+
class TestBitGeneratorMRG32k3a(BitGeneratorTestCase, unittest.TestCase):
67+
def setUp(self):
68+
super().setUp()
69+
self.bg = random._bit_generator.MRG32k3a
70+
71+
72+
@testing.with_requires("numpy>=1.17.0")
73+
@testing.fix_random()
74+
@pytest.mark.skipif(
75+
cupy.cuda.runtime.is_hip, reason="HIP does not support this"
76+
)
77+
class TestBitGeneratorPhilox4x3210(BitGeneratorTestCase, unittest.TestCase):
78+
def setUp(self):
79+
super().setUp()
80+
self.bg = random._bit_generator.Philox4x3210

0 commit comments

Comments
 (0)