Skip to content

Commit

Permalink
moved generated_quantities tests to test/model.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
torfjelde committed Sep 6, 2023
1 parent e4d964e commit a18b435
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
33 changes: 33 additions & 0 deletions test/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,37 @@ end
@test DynamicPPL.TestUtils.posterior_mean(model) isa typeof(x)
end
end

@testset "generated_quantities on `LKJCholesky`" begin
n = 10
d = 2
model = DynamicPPL.TestUtils.demo_lkjchol(d)
xs = [model().x for _ in 1:n]

# Extract varnames and values.
vns_and_vals_xs = map(
collect Base.Fix1(DynamicPPL.varname_and_value_leaves, @varname(x)), xs
)
vns = map(first, first(vns_and_vals_xs))
vals = map(vns_and_vals_xs) do vns_and_vals
map(last, vns_and_vals)
end

# Construct the chain.
syms = map(Symbol, vns)
vns_to_syms = OrderedDict(zip(vns, syms))

chain = MCMCChains.Chains(
permutedims(stack(vals)),
syms;
info = (varname_to_symbol = vns_to_syms,)
)
display(chain)

# Test!
results = generated_quantities(model, chain)
for (x_true, result) in zip(xs, results)
@test x_true.UL == result.x.UL
end
end
end
32 changes: 0 additions & 32 deletions test/nested_indexing.jl

This file was deleted.

0 comments on commit a18b435

Please sign in to comment.