From 1055a10070a4ffca2ffdd686549a4f135ba26c9c Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Fri, 29 Nov 2024 14:42:43 +0000 Subject: [PATCH] Add value_iterator_from_chain tests from test/turing/model.jl --- test/model_utils.jl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/model_utils.jl diff --git a/test/model_utils.jl b/test/model_utils.jl new file mode 100644 index 000000000..d45dc7136 --- /dev/null +++ b/test/model_utils.jl @@ -0,0 +1,18 @@ +@testset "model_utils.jl" begin + + @testset "value_iterator_from_chain" begin + @testset "$model" for model in DynamicPPL.TestUtils.DEMO_MODELS + chain = make_chain_from_prior(model, 10) + for (i, d) in enumerate(value_iterator_from_chain(model, chain)) + for vn in keys(d) + val = DynamicPPL.getvalue(d, vn) + for vn_leaf in DynamicPPL.varname_leaves(vn, val) + val_leaf = DynamicPPL.getvalue(d, vn_leaf) + @test val_leaf == chain[i, Symbol(vn_leaf), 1] + end + end + end + end + end + +end