Skip to content

Commit 51f1c8b

Browse files
committed
Sample lower chains first
1 parent 08603a4 commit 51f1c8b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pymc3/parallel_sampling.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,19 @@ def __init__(self, draws, tune, chains, cores, seeds, start_points,
247247
self._global_progress = self._progress = None
248248
if progressbar:
249249
self._global_progress = tqdm_(
250-
total=chains, unit='chains', position=1)
250+
total=chains, unit='chains', position=0)
251251
self._progress = [
252252
tqdm_(
253253
desc=' Chain %i' % (chain + start_chain_num),
254254
unit='draws',
255-
position=chain + 2,
255+
position=chain + 1,
256256
total=draws + tune)
257257
for chain in range(chains)
258258
]
259259

260260
def _make_active(self):
261261
while self._inactive and len(self._active) < self._max_active:
262-
proc = self._inactive.pop()
262+
proc = self._inactive.pop(0)
263263
proc.start()
264264
proc.write_next()
265265
self._active.append(proc)
@@ -282,6 +282,8 @@ def __iter__(self):
282282
self._make_active()
283283
if self._global_progress is not None:
284284
self._global_progress.update()
285+
if self._progress is not None:
286+
self._progress[proc.chain - self._start_chain_num].close()
285287

286288
yield Draw(
287289
proc.chain, is_last, draw, tuning,

0 commit comments

Comments
 (0)