Skip to content

Consolidate progress bar speed logic #7801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions pymc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,18 +857,6 @@ def _initialize_tasks(self):
for chain_idx in range(self.chains)
]

def compute_draw_speed(self, chain_idx, draws):
elapsed = self._progress.tasks[chain_idx].elapsed
speed = draws / max(elapsed, 1e-6)

if speed > 1 or speed == 0:
unit = "draws/s"
else:
unit = "s/draws"
speed = 1 / speed

return speed, unit

def update(self, chain_idx, is_last, draw, tuning, stats):
if not self._show_progress:
return
Expand All @@ -878,7 +866,8 @@ def update(self, chain_idx, is_last, draw, tuning, stats):
draw = self.completed_draws
chain_idx = 0

speed, unit = self.compute_draw_speed(chain_idx, draw)
elapsed = self._progress.tasks[chain_idx].elapsed
speed, unit = compute_draw_speed(elapsed, draw)

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