Skip to content

Commit b177aa3

Browse files
committed
Add test for nested (non-toplevel) model
1 parent 27a2df0 commit b177aa3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/compiler.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,22 @@ priors = 0 # See "new grammar" test.
213213
@test getlogp(varinfo) == lp
214214
@test varinfo === _varinfo
215215
end
216+
@testset "nested model" begin
217+
function nest(α_0, θ_0)
218+
@model gdemo(x) = begin
219+
λ ~ Gamma(α_0, θ_0)
220+
m ~ Normal(0, (1 / λ))
221+
x .~ Normal(m, (1 / λ))
222+
global lp = @logpdf()
223+
end
224+
225+
return gdemo
226+
end
227+
model = nest(2.0, inv(3.0))([1.5, 2.0])
228+
varinfo = DynamicPPL.VarInfo(model)
229+
model(varinfo)
230+
@test getlogp(varinfo) = lp
231+
end
216232
@testset "new grammar" begin
217233
x = Float64[1 2]
218234

0 commit comments

Comments
 (0)