Skip to content

Commit 58fdc72

Browse files
committed
add test
1 parent 08abb07 commit 58fdc72

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/mcmc/hmc.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,19 @@ using Turing
203203
return 10 ~ Normal(x)
204204
end
205205
chn1 = sample(StableRNG(468), f(), NUTS(), 100; save_state=true)
206-
chn2 = sample(StableRNG(468), f(), NUTS(), 10; initial_state=chn1.info.samplerstate)
207-
@test isapprox(chn1[:x], 5.0; atol=2.0)
206+
# chn1 should end up around x = 5.
207+
chn2 = sample(
208+
StableRNG(468),
209+
f(),
210+
NUTS(),
211+
10;
212+
nadapts=0,
213+
discard_adapt=false,
214+
initial_state=chn1.info.samplerstate,
215+
)
216+
# if chn2 uses initial_state, its first sample should be somewhere around 5. if
217+
# initial_state isn't used, it will be sampled from [-2, 2] so this test should fail
218+
@test isapprox(chn2[:x][1], 5.0; atol=2.0)
208219
end
209220

210221
@testset "(partially) issue: #2095" begin

0 commit comments

Comments
 (0)