Skip to content

Commit c6c9554

Browse files
committed
added model to updatestate!!
1 parent d1d4642 commit c6c9554

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

docs/src/api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function AbstractMCMC.step(rng, model::AbstractMCMC.AbstractModel, sampler::Mixt
161161
# the state and transition from the previous iteration.
162162
i_prev = state.index
163163
state_current = AbstractMCMC.updatestate!!(
164-
state.states[i], state.states[i_prev], state.transition
164+
model, state.states[i], state.states[i_prev], state.transition
165165
)
166166

167167
# Take a `step` for this sampler using the updated state.
@@ -217,7 +217,7 @@ end
217217
Suppose we then wanted to use this with some of the packages which implements AbstractMCMC.jl's interface, e.g. [`AdvancedMH.jl`](https://github.com/TuringLang/AdvancedMH.jl), then we'd simply have to implement `realize` and `realize!!`:
218218

219219
```julia
220-
function AbstractMCMC.updatestate!!(::AdvancedMH.Transition, state_prev::AdvancedMH.Transition)
220+
function AbstractMCMC.updatestate!!(model, ::AdvancedMH.Transition, state_prev::AdvancedMH.Transition)
221221
# Let's `deepcopy` just to be certain.
222222
return deepcopy(state_prev)
223223
end

src/AbstractMCMC.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,16 @@ The `MCMCSerial` algorithm allows users to sample serially, with no thread or pr
8080
struct MCMCSerial <: AbstractMCMCEnsemble end
8181

8282
"""
83-
updatestate!!(state, transition_prev[, state_prev])
83+
updatestate!!(model, state, transition_prev[, state_prev])
8484
85-
Return new instance of `state` using information from `transition_prev` and, optionally, `state_prev`.
85+
Return new instance of `state` using information from `model`, `transition_prev` and, optionally, `state_prev`.
8686
8787
Defaults to `realize!!(state, realize(transition_prev))`.
8888
"""
89-
updatestate!!(state, transition_prev, state_prev) = updatestate!!(state, transition_prev)
90-
updatestate!!(state, transition) = realize!!(state, realize(transition))
89+
function updatestate!!(model, state, transition_prev, state_prev)
90+
return updatestate!!(state, transition_prev)
91+
end
92+
updatestate!!(model, state, transition) = realize!!(state, realize(transition))
9193

9294
"""
9395
realize!!(state, realization)

0 commit comments

Comments
 (0)