Skip to content

Commit 6b7bc7c

Browse files
committed
chore: 修复面板进度条显示错误的问题
1 parent 94fbbde commit 6b7bc7c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def __init__(self, pbar: tqdm):
194194
self.pbar = pbar
195195
self._rate = pbar.smoothing
196196
self.speed: deque[float] = deque(maxlen=int(1.0 / self._rate) * 30)
197-
self._n = pbar.n
197+
self._n = float(pbar.n)
198198
self._start = time.monotonic()
199199
self._time = time.monotonic()
200200
self._last_time = self._time
@@ -237,9 +237,11 @@ def __exit__(self, exc_type, exc_val, exc_tb):
237237

238238
def update(self, n: float | None = 1):
239239
self.pbar.update(n)
240+
self._n += n or 1
240241
if time.monotonic() - self._time > 1:
241-
self.speed.append(self.pbar.n / (time.monotonic() - self._time))
242+
self.speed.append(self._n / (time.monotonic() - self._time))
242243
self._time = time.monotonic()
244+
self._n = 0
243245

244246
def set_postfix_str(self, s: str):
245247
self.pbar.set_postfix_str(s)

0 commit comments

Comments
 (0)