Skip to content

Commit 3b62f82

Browse files
authored
Consolidate progress bar speed logic (#7801)
1 parent 2ca26bc commit 3b62f82

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

pymc/util.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -857,18 +857,6 @@ def _initialize_tasks(self):
857857
for chain_idx in range(self.chains)
858858
]
859859

860-
def compute_draw_speed(self, chain_idx, draws):
861-
elapsed = self._progress.tasks[chain_idx].elapsed
862-
speed = draws / max(elapsed, 1e-6)
863-
864-
if speed > 1 or speed == 0:
865-
unit = "draws/s"
866-
else:
867-
unit = "s/draws"
868-
speed = 1 / speed
869-
870-
return speed, unit
871-
872860
def update(self, chain_idx, is_last, draw, tuning, stats):
873861
if not self._show_progress:
874862
return
@@ -878,7 +866,8 @@ def update(self, chain_idx, is_last, draw, tuning, stats):
878866
draw = self.completed_draws
879867
chain_idx = 0
880868

881-
speed, unit = self.compute_draw_speed(chain_idx, draw)
869+
elapsed = self._progress.tasks[chain_idx].elapsed
870+
speed, unit = compute_draw_speed(elapsed, draw)
882871

883872
if not tuning and stats and stats[0].get("diverging"):
884873
self.divergences += 1

0 commit comments

Comments
 (0)