Skip to content

Commit c985383

Browse files
committed
use collect for init_params when using MCMCThreads
1 parent 85deddb commit c985383

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/sample.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ function mcmcsample(
314314

315315
# Ensure that initial parameters are `nothing` or of the correct length
316316
check_initial_params(init_params, nchains)
317+
# We will use `getindex` later so we need to `collect`.
318+
_init_params = collect(init_params)
317319

318320
# Set up a chains vector.
319321
chains = Vector{Any}(undef, nchains)
@@ -364,10 +366,10 @@ function mcmcsample(
364366
_sampler,
365367
N;
366368
progress=false,
367-
init_params=if init_params === nothing
369+
init_params=if _init_params === nothing
368370
nothing
369371
else
370-
init_params[chainidx]
372+
_init_params[chainidx]
371373
end,
372374
kwargs...,
373375
)

0 commit comments

Comments
 (0)