Skip to content

Commit 365d671

Browse files
committed
Fix issues for legacy behavior with dpnp.random.uniform() and dpnp.random.seed() calls
1 parent 369419a commit 365d671

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

dpnp/backend/src/dpnp_random_state.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ void MT19937_Delete(mt19937_struct *mt19937) {
5454
mt19937->engine = nullptr;
5555
delete engine;
5656
return;
57-
}
57+
}

dpnp/random/dpnp_iface_random.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ def uniform(self, low=0.0, high=1.0, size=None, dtype=numpy.float64, usm_type="d
133133

134134
return call_origin(numpy.random.uniform, low, high, size)
135135

136-
137136
def _check_dims(dims):
138137
for dim in dims:
139138
if not isinstance(dim, int):
@@ -1370,7 +1369,13 @@ def seed(seed=None):
13701369
elif seed < 0:
13711370
pass
13721371
else:
1373-
dpnp_rng_srand(seed)
1372+
# TODO:
1373+
# migrate to a single approach with RandomState()
1374+
1375+
# update a mt19937 random number for both RandomState() class and legacy functionality
1376+
global dpnp_random_state
1377+
dpnp_random_state = RandomState(seed)
1378+
return dpnp_rng_srand(seed)
13741379

13751380
return call_origin(numpy.random.seed, seed)
13761381

@@ -1737,5 +1742,4 @@ def zipf(a, size=None):
17371742
return call_origin(numpy.random.zipf, a, size)
17381743

17391744

1740-
seed = 1
1741-
dpnp_random_state = RandomState(seed)
1745+
dpnp_random_state = RandomState()

0 commit comments

Comments
 (0)