Skip to content

Commit 0a667a4

Browse files
committed
reverted to for-loop
1 parent 85d938f commit 0a667a4

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/sample.jl

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,15 @@ function mcmcsample(
173173
end
174174
end
175175

176-
# Initialize iteration counter.
177-
i = 1
178-
179176
# Run callback.
180-
callback === nothing || callback(rng, model, sampler, sample, state, i; kwargs...)
177+
callback === nothing || callback(rng, model, sampler, sample, state, 1; kwargs...)
181178

182179
# Save the sample.
183180
samples = AbstractMCMC.samples(sample, model, sampler, N; kwargs...)
184-
samples = save!!(samples, sample, i, model, sampler, N; kwargs...)
185-
186-
# Step through remainder of warmup iterations and save.
187-
i += 1
181+
samples = save!!(samples, sample, 1, model, sampler, N; kwargs...)
188182

189183
# Step through the sampler.
190-
while i N
184+
for i = 2:N
191185
# Discard thinned samples.
192186
for _ in 1:(thinning - 1)
193187
# Obtain the next sample and state.
@@ -288,18 +282,14 @@ function mcmcsample(
288282
end
289283
end
290284

291-
# Initialize iteration counter.
292-
i = 1
293-
294285
# Run callback.
295-
callback === nothing || callback(rng, model, sampler, sample, state, i; kwargs...)
286+
callback === nothing || callback(rng, model, sampler, sample, state, 1; kwargs...)
296287

297288
# Save the sample.
298289
samples = AbstractMCMC.samples(sample, model, sampler; kwargs...)
299-
samples = save!!(samples, sample, i, model, sampler; kwargs...)
290+
samples = save!!(samples, sample, 1, model, sampler; kwargs...)
300291

301-
i += 1
302-
292+
i = 2
303293
while !isdone(rng, model, sampler, samples, state, i; progress=progress, kwargs...)
304294
# Discard thinned samples.
305295
for _ in 1:(thinning - 1)

0 commit comments

Comments
 (0)