Skip to content

Commit badd446

Browse files
test with and without parallelization across cores
demonstrates issue pymc-devs#3555
1 parent 4f67d63 commit badd446

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pymc3/tests/test_step.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ def test_checks_population_size(self):
915915
trace = sample(draws=100, chains=4, step=step)
916916
pass
917917

918-
def test_parallelized_chains_are_random(self):
918+
def test_nonparallelized_chains_are_random(self):
919919
with Model() as model:
920920
x = Normal("x", 0, 1)
921921
for stepper in TestPopulationSamplers.steppers:
@@ -928,6 +928,19 @@ def test_parallelized_chains_are_random(self):
928928
)
929929
pass
930930

931+
def test_parallelized_chains_are_random(self):
932+
with Model() as model:
933+
x = Normal("x", 0, 1)
934+
for stepper in TestPopulationSamplers.steppers:
935+
step = stepper()
936+
trace = sample(chains=4, draws=20, tune=0, step=DEMetropolis(), parallelize=True)
937+
samples = np.array(trace.get_values("x", combine=False))[:, 5]
938+
939+
assert len(set(samples)) == 4, "Parallelized {} " "chains are identical.".format(
940+
stepper
941+
)
942+
pass
943+
931944

932945
@pytest.mark.xfail(condition=(theano.config.floatX == "float32"), reason="Fails on float32")
933946
class TestNutsCheckTrace:

0 commit comments

Comments
 (0)