Skip to content

Commit 02ea145

Browse files
committed
Add a test
1 parent 406b237 commit 02ea145

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/mcmc/hmc.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,16 @@ using Turing
197197
@test_throws ErrorException sample(demo_impossible(), NUTS(), 5)
198198
end
199199

200+
@testset "NUTS initial parameters" begin
201+
@model function f()
202+
x ~ Normal()
203+
return 10 ~ Normal(x)
204+
end
205+
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)
208+
end
209+
200210
@testset "(partially) issue: #2095" begin
201211
@model function vector_of_dirichlet((::Type{TV})=Vector{Float64}) where {TV}
202212
xs = Vector{TV}(undef, 2)

0 commit comments

Comments
 (0)