Skip to content

Commit 90d0ec7

Browse files
committed
Add tests
1 parent 7247816 commit 90d0ec7

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

test/turing.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
return nothing
99
end
1010

11+
@model logp_check() = x ~ Normal()
12+
1113
n_samples = 1000
12-
model = demo()
14+
model = demo()
1315

1416
@testset for sampler in [
1517
RandPermGibbs(Slice(1)),
@@ -30,6 +32,11 @@
3032
)
3133

3234
chain = sample(model, externalsampler(sampler), n_samples; progress=false)
35+
36+
chain_logp_check = sample(
37+
logp_check(), externalsampler(sampler), 100; progress=false
38+
)
39+
@test isapprox(logpdf.(Normal(), chain_logp_check[:x]), chain_logp_check[:logp])
3340
end
3441

3542
@testset "gibbs($sampler)" for sampler in [
@@ -46,5 +53,10 @@
4653
n_samples;
4754
progress=false,
4855
)
56+
57+
chain_logp_check = sample(
58+
logp_check(), Turing.Gibbs(:x => externalsampler(sampler)), 100; progress=false
59+
)
60+
@test isapprox(logpdf.(Normal(), chain_logp_check[:x]), chain_logp_check[:logp])
4961
end
5062
end

0 commit comments

Comments
 (0)