Skip to content

Commit

Permalink
Include sample_z in _cleanup_samples()
Browse files Browse the repository at this point in the history
  • Loading branch information
Micki-D authored and oschulz committed Nov 16, 2024
1 parent 4d2f76b commit 62c600d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/samplers/mcmc/mcmc_state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ end


function mcmc_step!!(mcmc_state::MCMCState)
# TODO: MD, include sample_z in _cleanup_samples()
_cleanup_samples(mcmc_state)

reset_rng_counters!(mcmc_state)
Expand Down Expand Up @@ -194,6 +193,9 @@ function _cleanup_samples(chain_state::MCMCChainState)
samples = chain_state.samples
current = _current_sample_idx(chain_state)
proposed = _proposed_sample_idx(chain_state)
sample_z = chain_state.sample_z
current_z = _current_sample_z_idx(chain_state)
proposed_z = _proposed_sample_z_idx(chain_state)
if (current != proposed) && samples.info.sampletype[proposed] == CURRENT_SAMPLE
# Proposal was accepted in the last step
@assert samples.info.sampletype[current] == ACCEPTED_SAMPLE
Expand All @@ -203,6 +205,9 @@ function _cleanup_samples(chain_state::MCMCChainState)
samples.info[current] = samples.info[proposed]

resize!(samples, 1)
# TODO: MD, discuss the usage of sample_z, and if it stays, clean it up and use proper info
sample_z.v[current_z] .= sample_z.v[proposed_z]
sample_z.logd[current_z] = sample_z.logd[proposed_z]
end
end

Expand Down

0 comments on commit 62c600d

Please sign in to comment.