From ee74bfbe304a39e67426118ed3cb94c77d8813e2 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Wed, 10 Feb 2021 11:34:59 +0000 Subject: [PATCH] fix `reset()` & `unpause()` when disabled - fixes #1125 --- tqdm/std.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tqdm/std.py b/tqdm/std.py index 70026348..17bc5c6f 100644 --- a/tqdm/std.py +++ b/tqdm/std.py @@ -1330,6 +1330,8 @@ class tqdm(Comparable): def unpause(self): """Restart tqdm timer from last print time.""" + if self.disable: + return cur_t = self._time() self.start_t += cur_t - self.last_print_t self.last_print_t = cur_t @@ -1344,13 +1346,16 @@ class tqdm(Comparable): ---------- total : int or float, optional. Total to use for the new bar. """ - self.last_print_n = self.n = 0 + self.n = 0 + if total is not None: + self.total = total + if self.disable: + return + self.last_print_n = 0 self.last_print_t = self.start_t = self._time() self._ema_dn = EMA(self.smoothing) self._ema_dt = EMA(self.smoothing) self._ema_miniters = EMA(self.smoothing) - if total is not None: - self.total = total self.refresh() def set_description(self, desc=None, refresh=True):