fix `reset()` & `unpause()` when disabled

- fixes #1125
This commit is contained in:
Casper da Costa-Luis 2021-02-10 11:34:59 +00:00
parent 94842e1027
commit ee74bfbe30
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
1 changed files with 8 additions and 3 deletions

View File

@ -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):