Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Tor Erlend Fjelde <[email protected]>
  • Loading branch information
sunxd3 and torfjelde authored Oct 25, 2024
1 parent 2d0292c commit 6855840
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/AbstractMCMC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,12 @@ The `MCMCSerial` algorithm allows users to sample serially, with no thread or pr
struct MCMCSerial <: AbstractMCMCEnsemble end

"""
getparams(model::AbstractModel, state)
getparams(logdensity, state)
getparams(state)
getparams([model::AbstractModel, ]state)
Retrieve the values of parameters from the sampler's `state` as a `Vector{<:Real}`.
"""
function getparams end

function getparams(logdensity, state)
return getparams(_model(logdensity), state)
end

function getparams(model::AbstractModel, state)
return getparams(state)
end
Expand All @@ -111,17 +105,11 @@ Although not enforced, it should hold that `setparams!!(state, getparams(state))
words, the sampler should implement a consistent transformation between its internal representation
and the vector representation of the parameter values.
Sometimes, to maintain the consistency of the log density and parameter values, a `model::AbstractModel`
Sometimes, to maintain the consistency of the log density and parameter values, a `model`
should be provided. This is useful for samplers that need to evaluate the log density at the new parameter values.
If `model` is not an `AbstractMCMC.AbstractModel`, by default, it is assumed to be a log density function following
the `LogDensityProblems.jl` interface, and will be wrapped with [`AbstractMCMC.LogDensityModel`](@ref).
"""
function setparams!! end

function setparams!!(logdensity, state, params)
return setparams!!(_model(logdensity), state, params)
end

function setparams!!(model::AbstractModel, state, params)
return setparams!!(state, params)
end
Expand Down

0 comments on commit 6855840

Please sign in to comment.