From 6b7bc7c45d58470cface02b979dfba1342dd7674 Mon Sep 17 00:00:00 2001 From: tianxiu2b2t <atianxiua@163.com> Date: Tue, 21 Jan 2025 20:36:55 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BF=AE=E5=A4=8D=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E6=9D=A1=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/utils.py b/core/utils.py index 86518a6..2af6960 100644 --- a/core/utils.py +++ b/core/utils.py @@ -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 @@ -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)