Skip to content

Fix missing field tests for 1.12 #961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions test/varinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,12 @@ end
),
)
@test getlogprior(vi) == lp_a + lp_b
@test_throws "has no field LogLikelihood" getloglikelihood(vi)
@test_throws "has no field LogLikelihood" getlogp(vi)
@test_throws "has no field LogLikelihood" getlogjoint(vi)
@test_throws "has no field NumProduce" get_num_produce(vi)
# need regex because 1.11 and 1.12 throw different errors (in 1.12 the
# missing field is surrounded by backticks)
@test_throws r"has no field `?LogLikelihood" getloglikelihood(vi)
@test_throws r"has no field `?LogLikelihood" getlogp(vi)
@test_throws r"has no field `?LogLikelihood" getlogjoint(vi)
@test_throws r"has no field `?NumProduce" get_num_produce(vi)
@test begin
vi = acclogprior!!(vi, 1.0)
getlogprior(vi) == lp_a + lp_b + 1.0
Expand All @@ -229,20 +231,24 @@ end
m, DynamicPPL.setaccs!!(deepcopy(vi), (NumProduceAccumulator(),))
),
)
@test_throws "has no field LogPrior" getlogprior(vi)
@test_throws "has no field LogLikelihood" getloglikelihood(vi)
@test_throws "has no field LogPrior" getlogp(vi)
@test_throws "has no field LogPrior" getlogjoint(vi)
# need regex because 1.11 and 1.12 throw different errors (in 1.12 the
# missing field is surrounded by backticks)
@test_throws r"has no field `?LogPrior" getlogprior(vi)
@test_throws r"has no field `?LogLikelihood" getloglikelihood(vi)
@test_throws r"has no field `?LogPrior" getlogp(vi)
@test_throws r"has no field `?LogPrior" getlogjoint(vi)
@test get_num_produce(vi) == 2

# Test evaluating without any accumulators.
vi = last(DynamicPPL.evaluate!!(m, DynamicPPL.setaccs!!(deepcopy(vi), ())))
@test_throws "has no field LogPrior" getlogprior(vi)
@test_throws "has no field LogLikelihood" getloglikelihood(vi)
@test_throws "has no field LogPrior" getlogp(vi)
@test_throws "has no field LogPrior" getlogjoint(vi)
@test_throws "has no field NumProduce" get_num_produce(vi)
@test_throws "has no field NumProduce" reset_num_produce!!(vi)
# need regex because 1.11 and 1.12 throw different errors (in 1.12 the
# missing field is surrounded by backticks)
@test_throws r"has no field `?LogPrior" getlogprior(vi)
@test_throws r"has no field `?LogLikelihood" getloglikelihood(vi)
@test_throws r"has no field `?LogPrior" getlogp(vi)
@test_throws r"has no field `?LogPrior" getlogjoint(vi)
@test_throws r"has no field `?NumProduce" get_num_produce(vi)
@test_throws r"has no field `?NumProduce" reset_num_produce!!(vi)
end

@testset "flags" begin
Expand Down
Loading