Skip to content

Commit 700ae06

Browse files
authored
Merge pull request #133 from TuringLang/tor/context-tests
Added a small test for different contexts and its interaction with VarInfo
2 parents 0ec0bb6 + 33ae31d commit 700ae06

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/varinfo.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ include(dir*"/test/test_utils/AllUtils.jl")
4646
@test all(meta.vals[range] .== fmeta.vals[trange])
4747
end
4848
end
49+
50+
contexts = [
51+
DynamicPPL.DefaultContext(),
52+
DynamicPPL.MiniBatchContext(DynamicPPL.DefaultContext(), 1.),
53+
DynamicPPL.LikelihoodContext(),
54+
DynamicPPL.PriorContext()
55+
]
56+
vis = map(contexts) do ctx
57+
VarInfo(model, ctx)
58+
end
59+
60+
vns = fieldnames(typeof(first(vis).metadata)) # default context
61+
for (vi, ctx) in zip(vis, contexts)
62+
vns_ctx = fieldnames(typeof(vi.metadata))
63+
@test vns_ctx == vns
64+
end
4965
end
5066
@testset "Base" begin
5167
# Test Base functions:

0 commit comments

Comments
 (0)