Skip to content

Make all MLDA tests deterministic #4313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Changes from all commits
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
6 changes: 3 additions & 3 deletions pymc3/tests/test_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ def test_nonparallelized_chains_are_random(self):
Normal("x", 0, 1)
for stepper in TestMLDA.steppers:
step = stepper(coarse_models=[coarse_model])
trace = sample(chains=2, cores=1, draws=20, tune=0, step=step)
trace = sample(chains=2, cores=1, draws=20, tune=0, step=step, random_seed=1)
samples = np.array(trace.get_values("x", combine=False))[:, 5]
assert (
len(set(samples)) == 2
Expand All @@ -1150,7 +1150,7 @@ def test_parallelized_chains_are_random(self):
Normal("x", 0, 1)
for stepper in TestMLDA.steppers:
step = stepper(coarse_models=[coarse_model])
trace = sample(chains=2, cores=2, draws=20, tune=0, step=step)
trace = sample(chains=2, cores=2, draws=20, tune=0, step=step, random_seed=1)
samples = np.array(trace.get_values("x", combine=False))[:, 5]
assert len(set(samples)) == 2, "Parallelized {} " "chains are identical.".format(
stepper
Expand All @@ -1176,7 +1176,7 @@ def test_acceptance_rate_against_coarseness(self):
Normal("x", 5.0, 1.0)
for coarse_model in possible_coarse_models:
step = MLDA(coarse_models=[coarse_model], subsampling_rates=3)
trace = sample(chains=1, draws=500, tune=100, step=step)
trace = sample(chains=1, draws=500, tune=100, step=step, random_seed=1)
acc.append(trace.get_sampler_stats("accepted").mean())
assert acc[0] > acc[1] > acc[2], (
"Acceptance rate is not "
Expand Down