Skip to content

Commit

Permalink
chore: 修复面板进度条显示错误的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxiu2b2t committed Jan 21, 2025
1 parent 94fbbde commit 6b7bc7c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def __init__(self, pbar: tqdm):
self.pbar = pbar
self._rate = pbar.smoothing
self.speed: deque[float] = deque(maxlen=int(1.0 / self._rate) * 30)
self._n = pbar.n
self._n = float(pbar.n)
self._start = time.monotonic()
self._time = time.monotonic()
self._last_time = self._time
Expand Down Expand Up @@ -237,9 +237,11 @@ def __exit__(self, exc_type, exc_val, exc_tb):

def update(self, n: float | None = 1):
self.pbar.update(n)
self._n += n or 1
if time.monotonic() - self._time > 1:
self.speed.append(self.pbar.n / (time.monotonic() - self._time))
self.speed.append(self._n / (time.monotonic() - self._time))
self._time = time.monotonic()
self._n = 0

def set_postfix_str(self, s: str):
self.pbar.set_postfix_str(s)
Expand Down

0 comments on commit 6b7bc7c

Please sign in to comment.