Skip to content

Commit c4683fb

Browse files
michaelosthegericardoV94
authored andcommitted
Seed TestTP and TestLatentKron against flakyness
Related to #6299
1 parent 1a143b7 commit c4683fb

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pymc/tests/gp/test_gp.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,11 @@ class TestTP:
358358
"""
359359

360360
def setup_method(self):
361-
X = np.random.randn(20, 3)
362-
y = np.random.randn(20)
363-
Xnew = np.random.randn(30, 3)
364-
pnew = np.random.randn(30)
361+
rng = np.random.default_rng(20221125)
362+
X = rng.standard_normal(size=(20, 3))
363+
y = rng.standard_normal(size=(20,))
364+
Xnew = rng.standard_normal(size=(30, 3))
365+
pnew = rng.standard_normal(size=(30,))
365366

366367
with pm.Model() as model1:
367368
cov_func = pm.gp.cov.ExpQuad(3, [0.1, 0.2, 0.3])
@@ -414,6 +415,7 @@ class TestLatentKron:
414415
"""
415416

416417
def setup_method(self):
418+
rng = np.random.default_rng(20221125)
417419
self.Xs = [
418420
np.linspace(0, 1, 7)[:, None],
419421
np.linspace(0, 1, 5)[:, None],
@@ -422,9 +424,13 @@ def setup_method(self):
422424
self.X = cartesian(*self.Xs)
423425
self.N = np.prod([len(X) for X in self.Xs])
424426
self.y = np.random.randn(self.N) * 0.1
425-
self.Xnews = (np.random.randn(5, 1), np.random.randn(5, 1), np.random.randn(5, 1))
427+
self.Xnews = (
428+
rng.standard_normal(size=(5, 1)),
429+
rng.standard_normal(size=(5, 1)),
430+
rng.standard_normal(size=(5, 1)),
431+
)
426432
self.Xnew = np.concatenate(self.Xnews, axis=1)
427-
self.pnew = np.random.randn(len(self.Xnew))
433+
self.pnew = rng.standard_normal(size=(len(self.Xnew),))
428434
ls = 0.2
429435
with pm.Model() as latent_model:
430436
self.cov_funcs = (

0 commit comments

Comments
 (0)