Skip to content

Commit

Permalink
Added test for correct values in discard during hierarchical update
Browse files Browse the repository at this point in the history
  • Loading branch information
yifr committed Jul 2, 2024
1 parent 659afba commit 92d73be
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/dsl/dynamic_dsl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,19 @@ end
@test isapprox(expected_new_score, get_score(new_trace))
@test isapprox(expected_weight, weight)
@test retdiff === UnknownChange()

# Test correct discarding for hierarchical choicemap update
@gen function hierarchical_update()
k ~ poisson(5)
for i=1:k
{:value => i} ~ uniform(0,1)
end
end
tr, = Gen.generate(hierarchical_update, (), choicemap(:k=>3));
# update k, affecting the number of children
(new_trace, weight, _, discard) = Gen.update(tr, Gen.choicemap(:k=>1));
@test Gen.has_value(discard, :value => 2)
@test Gen.has_value(discard, :value => 3)
end

@testset "regenerate" begin
Expand Down

0 comments on commit 92d73be

Please sign in to comment.