From 3c00914514dcaebf18b43b30f5c488ee1e7fb292 Mon Sep 17 00:00:00 2001 From: Markus Hauru Date: Wed, 26 Jun 2024 10:43:35 +0100 Subject: [PATCH] Bump DynamicPPL to v0.28 --- Project.toml | 2 +- src/mcmc/Inference.jl | 2 +- src/mcmc/mh.jl | 2 +- src/optimisation/Optimisation.jl | 4 +++- 4 files changed, 6 insertions(+), 4 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..f8e578718 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(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)