Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
devmotion and github-actions[bot] authored Oct 27, 2023
1 parent 3a38bd1 commit 3a2502f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion ext/DynamicPPLMCMCChainsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ end
# Load state from a `Chains`: By convention, it is stored in `:samplerstate` metadata
function DynamicPPL.loadstate(chain::MCMCChains.Chains)
if !haskey(chain.info, :samplerstate)
throw(ArgumentError("The chain object does not contain the final state of the sampler: Metadata `:samplerstate` missing."))
throw(
ArgumentError(
"The chain object does not contain the final state of the sampler: Metadata `:samplerstate` missing.",
),
)
end
return chain.info[:samplerstate]
end
Expand Down
6 changes: 4 additions & 2 deletions src/sampler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ function AbstractMCMC.sample(
N::Integer;
chain_type=default_chain_type(sampler),
resume_from=nothing,
kwargs...
kwargs...,
)
initial_state = loadstate(resume_from)
return AbstractMCMC.mcmcsample(rng, model, sampler, N; chain_type, initial_state, kwargs...)
return AbstractMCMC.mcmcsample(
rng, model, sampler, N; chain_type, initial_state, kwargs...
)
end

# initial step: general interface for resuming and
Expand Down

0 comments on commit 3a2502f

Please sign in to comment.