From 927abcd979eb49adc76cdfea13db4929fde41cd7 Mon Sep 17 00:00:00 2001 From: Markus Hauru Date: Wed, 26 Jun 2024 15:33:53 +0200 Subject: [PATCH] Bump DynamicPPL to v0.28 (#2276) * Bump DynamicPPL to v0.28 * Also bump DPPL to v0.28 in tests * Qualify use of getcontext --- Project.toml | 2 +- src/mcmc/Inference.jl | 2 +- src/mcmc/mh.jl | 2 +- src/optimisation/Optimisation.jl | 4 +++- test/Project.toml | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 3ee30eb95..5bf3336f3 100644 --- a/Project.toml +++ b/Project.toml @@ -63,7 +63,7 @@ Distributions = "0.23.3, 0.24, 0.25" DistributionsAD = "0.6" DocStringExtensions = "0.8, 0.9" DynamicHMC = "3.4" -DynamicPPL = "0.27.1" +DynamicPPL = "0.28" Compat = "4.15.0" EllipticalSliceSampling = "0.5, 1, 2" ForwardDiff = "0.10.3" diff --git a/src/mcmc/Inference.jl b/src/mcmc/Inference.jl index 7a0c541da..4f1f423c1 100644 --- a/src/mcmc/Inference.jl +++ b/src/mcmc/Inference.jl @@ -149,7 +149,7 @@ getADType(::DynamicPPL.IsParent, ctx::DynamicPPL.AbstractContext) = getADType(Dy getADType(alg::Hamiltonian) = alg.adtype function LogDensityProblemsAD.ADgradient(ℓ::DynamicPPL.LogDensityFunction) - return LogDensityProblemsAD.ADgradient(getADType(ℓ.context), ℓ) + return LogDensityProblemsAD.ADgradient(getADType(DynamicPPL.getcontext(ℓ)), ℓ) end function LogDensityProblems.logdensity( diff --git a/src/mcmc/mh.jl b/src/mcmc/mh.jl index 9b7f3ff09..ffc064eb1 100644 --- a/src/mcmc/mh.jl +++ b/src/mcmc/mh.jl @@ -271,7 +271,7 @@ function LogDensityProblems.logdensity(f::MHLogDensityFunction, x::NamedTuple) x_old, lj_old = vi[sampler], getlogp(vi) set_namedtuple!(vi, x) - vi_new = last(DynamicPPL.evaluate!!(f.model, vi, f.context)) + vi_new = last(DynamicPPL.evaluate!!(f.model, vi, DynamicPPL.getcontext(f))) lj = getlogp(vi_new) # Reset old `vi`. diff --git a/src/optimisation/Optimisation.jl b/src/optimisation/Optimisation.jl index 82bda7da7..e06989792 100644 --- a/src/optimisation/Optimisation.jl +++ b/src/optimisation/Optimisation.jl @@ -142,7 +142,9 @@ required by Optimization.jl. """ function (f::OptimLogDensity)(z::AbstractVector) varinfo = DynamicPPL.unflatten(f.varinfo, z) - return -DynamicPPL.getlogp(last(DynamicPPL.evaluate!!(f.model, varinfo, f.context))) + return -DynamicPPL.getlogp( + last(DynamicPPL.evaluate!!(f.model, varinfo, DynamicPPL.getcontext(f))) + ) end (f::OptimLogDensity)(z, _) = f(z) diff --git a/test/Project.toml b/test/Project.toml index a7538afbf..67292d2af 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -45,7 +45,7 @@ Clustering = "0.14, 0.15" Distributions = "0.25" DistributionsAD = "0.6.3" DynamicHMC = "2.1.6, 3.0" -DynamicPPL = "0.27" +DynamicPPL = "0.28" FiniteDifferences = "0.10.8, 0.11, 0.12" ForwardDiff = "0.10.12 - 0.10.32, 0.10" HypothesisTests = "0.11"