Skip to content

Commit

Permalink
replaces more references to f.context with getcontext(f)
Browse files Browse the repository at this point in the history
  • Loading branch information
torfjelde committed Jun 18, 2024
1 parent 92b2102 commit dfd8a8f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/logdensityfunction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct LogDensityFunction{V,M,C}
varinfo::V
"model used for evaluation"
model::M
"context used for evaluation; if `nothing`, `model.context` will be used when applicable"
"context used for evaluation; if `nothing`, `leafcontext(model.context)` will be used when applicable"
context::C
end

Expand Down Expand Up @@ -78,8 +78,8 @@ end

# HACK: heavy usage of `AbstractSampler` for, well, _everything_, is being phased out. In the mean time
# we need to define these annoying methods to ensure that we stay compatible with everything.
getsampler(f::LogDensityFunction) = getsampler(f.context)
hassampler(f::LogDensityFunction) = hassampler(f.context)
getsampler(f::LogDensityFunction) = getsampler(getcontext(f))
hassampler(f::LogDensityFunction) = hassampler(getcontext(f))

_get_indexer(ctx::AbstractContext) = _get_indexer(NodeTrait(ctx), ctx)
_get_indexer(ctx::SamplingContext) = ctx.sampler
Expand All @@ -91,7 +91,7 @@ _get_indexer(::IsLeaf, ctx::AbstractContext) = Colon()
Return the parameters of the wrapped varinfo as a vector.
"""
getparams(f::LogDensityFunction) = f.varinfo[_get_indexer(f.context)]
getparams(f::LogDensityFunction) = f.varinfo[_get_indexer(getcontext(f))]

# LogDensityProblems interface
function LogDensityProblems.logdensity(f::LogDensityFunction, θ::AbstractVector)
Expand Down

0 comments on commit dfd8a8f

Please sign in to comment.