From e67acdc753f5fbff1af0f6619ff446e639a7e32a Mon Sep 17 00:00:00 2001 From: Will Dean Date: Sat, 24 May 2025 08:42:07 -0400 Subject: [PATCH 1/2] consolidate progress bar function --- pymc/util.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/pymc/util.py b/pymc/util.py index 979b3beebf..a338c7e02a 100644 --- a/pymc/util.py +++ b/pymc/util.py @@ -859,15 +859,7 @@ def _initialize_tasks(self): 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 + return compute_draw_speed(elapsed, draws) def update(self, chain_idx, is_last, draw, tuning, stats): if not self._show_progress: From 095d448757602d0336f0fae515c369e39a106e1d Mon Sep 17 00:00:00 2001 From: Will Dean Date: Sat, 24 May 2025 08:48:50 -0400 Subject: [PATCH 2/2] remove the method in favor of function --- pymc/util.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pymc/util.py b/pymc/util.py index a338c7e02a..224ce0fa9c 100644 --- a/pymc/util.py +++ b/pymc/util.py @@ -857,10 +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 - return compute_draw_speed(elapsed, draws) - def update(self, chain_idx, is_last, draw, tuning, stats): if not self._show_progress: return @@ -870,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