Skip to content

Commit

Permalink
Add tests for get/set/acc/resetlogp
Browse files Browse the repository at this point in the history
  • Loading branch information
penelopeysm committed Dec 1, 2024
1 parent 408a6c6 commit e791193
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/varinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,25 @@ DynamicPPL.getspace(::DynamicPPL.Sampler{MySAlg}) = (:s,)
test_base!!(SimpleVarInfo(DynamicPPL.VarNamedVector()))
end

@testset "get/set/acc/resetlogp" begin
function test_varinfo_logp!(vi)
@test DynamicPPL.getlogp(vi) === 0.0
vi = DynamicPPL.setlogp!!(vi, 1)
@test DynamicPPL.getlogp(vi) === 1.0
vi = DynamicPPL.acclogp!!(vi, 1)
@test DynamicPPL.getlogp(vi) === 2.0
vi = DynamicPPL.resetlogp!!(vi)
@test DynamicPPL.getlogp(vi) === 0.0
end

vi = VarInfo()
test_varinfo_logp!!(vi)
test_varinfo_logp!!(TypedVarInfo(vi))
test_varinfo_logp!!(SimpleVarInfo())
test_varinfo_logp!!(SimpleVarInfo(Dict()))
test_varinfo_logp!!(SimpleVarInfo(DynamicPPL.VarNamedVector()))
end

@testset "flags" begin
# Test flag setting:
# is_flagged, set_flag!, unset_flag!
Expand Down

0 comments on commit e791193

Please sign in to comment.