Skip to content

Commit 8a808f1

Browse files
add regression test for pymc-devs#3733
1 parent bb574a7 commit 8a808f1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pymc3/tests/test_step.py

+21
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,27 @@ def test_parallelized_chains_are_random(self):
779779
pass
780780

781781

782+
class TestMetropolis:
783+
def test_tuning_reset(self):
784+
"""Re-use of the step method instance with cores=1 must not leak tuning information between chains."""
785+
with Model() as pmodel:
786+
D = 3
787+
Normal('n', 0, 2, shape=(D,))
788+
trace = sample(
789+
tune=600,
790+
draws=500,
791+
step=Metropolis(tune=True, scaling=0.1),
792+
cores=1,
793+
chains=3,
794+
discard_tuned_samples=False
795+
)
796+
for c in range(trace.nchains):
797+
# check that the tuned settings changed and were reset
798+
assert trace.get_sampler_stats('scaling', chains=c)[0] == 0.1
799+
assert trace.get_sampler_stats('scaling', chains=c)[-1] != 0.1
800+
pass
801+
802+
782803
class TestDEMetropolisZ:
783804
def test_tuning_lambda_sequential(self):
784805
with Model() as pmodel:

0 commit comments

Comments
 (0)