Skip to content

Commit 7deb93e

Browse files
committed
Use map instead of for
1 parent e94dd22 commit 7deb93e

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/sample.jl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -459,16 +459,12 @@ function mcmcsample(
459459
@warn "Number of chains ($nchains) is greater than number of samples per chain ($N)"
460460
end
461461

462-
# Set up a chains vector.
463-
chains = Vector{Any}(undef, nchains)
464-
465-
# Sample each chain
466-
for i in 1:nchains
467-
# Sample a chain and save it to the vector.
468-
chains[i] = StatsBase.sample(rng, model, sampler, N;
469-
progressname = string(progressname, " (Chain $i of $nchains)"),
470-
kwargs...)
471-
end
462+
# Sample the chains.
463+
chains = map(
464+
i -> StatsBase.sample(rng, model, sampler, N; progressname = string(progressname, " (Chain $i of $nchains)"),
465+
kwargs...),
466+
1:nchains
467+
)
472468

473469
# Concatenate the chains together.
474470
return chainsstack(tighten_eltype(chains))

0 commit comments

Comments
 (0)