|
29 | 29 |
|
30 | 30 | """
|
31 | 31 | sample(
|
32 |
| - rng::Random.AbatractRNG=Random.default_rng(), |
| 32 | + rng::Random.AbstractRNG=Random.default_rng(), |
33 | 33 | model::AbstractModel,
|
34 | 34 | sampler::AbstractSampler,
|
35 | 35 | N_or_isdone;
|
@@ -227,6 +227,10 @@ function mcmcsample(
|
227 | 227 | duration = stop - start
|
228 | 228 | stats = SamplingStats(start, stop, duration)
|
229 | 229 |
|
| 230 | + # Stop the progress bar |
| 231 | + ProgressMeter.finish!(progress_obj; keep=true) |
| 232 | + _progress_channel === nothing || put!(_progress_channel, (_chain_idx, false)) |
| 233 | + |
230 | 234 | return bundle_samples(
|
231 | 235 | samples,
|
232 | 236 | model,
|
@@ -429,22 +433,20 @@ function mcmcsample(
|
429 | 433 | channel = Distributed.RemoteChannel(() -> Channel{Tuple{Int,Bool}}(), 1)
|
430 | 434 |
|
431 | 435 | 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 |
448 | 450 | end
|
449 | 451 | end
|
450 | 452 |
|
@@ -566,22 +568,20 @@ function mcmcsample(
|
566 | 568 | channel = Distributed.RemoteChannel(() -> Channel{Tuple{Int,Bool}}(), 1)
|
567 | 569 |
|
568 | 570 | 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 |
585 | 585 | end
|
586 | 586 | end
|
587 | 587 |
|
|
0 commit comments