Skip to content

Commit 6d21ca5

Browse files
committed
cosmetic changes
1 parent 72c9d6c commit 6d21ca5

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

src/sample.jl

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ end
2929

3030
"""
3131
sample(
32-
rng::Random.AbatractRNG=Random.default_rng(),
32+
rng::Random.AbstractRNG=Random.default_rng(),
3333
model::AbstractModel,
3434
sampler::AbstractSampler,
3535
N_or_isdone;
@@ -227,6 +227,10 @@ function mcmcsample(
227227
duration = stop - start
228228
stats = SamplingStats(start, stop, duration)
229229

230+
# Stop the progress bar
231+
ProgressMeter.finish!(progress_obj; keep=true)
232+
_progress_channel === nothing || put!(_progress_channel, (_chain_idx, false))
233+
230234
return bundle_samples(
231235
samples,
232236
model,
@@ -429,22 +433,20 @@ function mcmcsample(
429433
channel = Distributed.RemoteChannel(() -> Channel{Tuple{Int,Bool}}(), 1)
430434

431435
Distributed.@sync begin
432-
Distributed.@async begin
433-
while true
434-
i, res = take!(channel)
435-
# i == 0 means the overall progress bar; i > 0 means the
436-
# progress bar for chain i.
437-
prog_obj = if i == 0
438-
overall_progress_obj
439-
else
440-
progress_objs[i]
441-
end
442-
if res # true = a chain / sample finished
443-
ProgressMeter.next!(prog_obj)
444-
else # false = all chains / samples finished (or one failed)
445-
ProgressMeter.finish!(prog_obj)
446-
break
447-
end
436+
Distributed.@async while true
437+
i, res = take!(channel)
438+
# i == 0 means the overall progress bar; i > 0 means the
439+
# progress bar for chain i.
440+
prog_obj = if i == 0
441+
overall_progress_obj
442+
else
443+
progress_objs[i]
444+
end
445+
if res # true = a chain / sample finished
446+
ProgressMeter.next!(prog_obj)
447+
else # false = all chains / samples finished (or one failed)
448+
ProgressMeter.finish!(prog_obj)
449+
i == 0 && break
448450
end
449451
end
450452

@@ -566,22 +568,20 @@ function mcmcsample(
566568
channel = Distributed.RemoteChannel(() -> Channel{Tuple{Int,Bool}}(), 1)
567569

568570
Distributed.@sync begin
569-
Distributed.@async begin
570-
while true
571-
i, res = take!(channel)
572-
# i == 0 means the overall progress bar; i > 0 means the
573-
# progress bar for chain i.
574-
prog_obj = if i == 0
575-
overall_progress_obj
576-
else
577-
progress_objs[i]
578-
end
579-
if res # true = a chain / sample finished
580-
ProgressMeter.next!(prog_obj)
581-
else # false = all chains / samples finished (or one failed)
582-
ProgressMeter.finish!(prog_obj)
583-
break
584-
end
571+
Distributed.@async while true
572+
i, res = take!(channel)
573+
# i == 0 means the overall progress bar; i > 0 means the
574+
# progress bar for chain i.
575+
prog_obj = if i == 0
576+
overall_progress_obj
577+
else
578+
progress_objs[i]
579+
end
580+
if res # true = a chain / sample finished
581+
ProgressMeter.next!(prog_obj)
582+
else # false = all chains / samples finished (or one failed)
583+
ProgressMeter.finish!(prog_obj; keep=true)
584+
i == 0 && break
585585
end
586586
end
587587

0 commit comments

Comments
 (0)