Skip to content

Commit

Permalink
Add a test for values_as_in_model(rng, model, ...)
Browse files Browse the repository at this point in the history
  • Loading branch information
penelopeysm committed Dec 21, 2024
1 parent edbfe3a commit dea62bb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,22 @@ const GDEMO_DEFAULT = DynamicPPL.TestUtils.demo_assume_observe_literal()
end
end
end

@testset "check that sampling obeys rng if passed" begin
@model function f()
x ~ Normal(0)
return y ~ Normal(x)
end
model = f()
# Call values_as_in_model with the rng
values = values_as_in_model(Random.Xoshiro(43), model, false)
# Check that they match the values that would be used if vi was seeded
# with that seed instead
expected_vi = VarInfo(Random.Xoshiro(43), model)
for vn in keys(values)
@test values[vn] == expected_vi[vn]
end
end
end

@testset "Erroneous model call" begin
Expand Down

0 comments on commit dea62bb

Please sign in to comment.