-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix over-estimated rate #96
Conversation
Current coverage is
|
@@ -194,7 +194,7 @@ def __iter__(self): | |||
|
|||
ax.set_title(format_meter( | |||
n, total, elapsed, 0, | |||
self.desc, ascii, unit, unit_scale, avg_rate, | |||
self.desc, ascii, unit, unit_scale, 1 / avg_time, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be 1 / avg_time if avg_time else None
like in _tqdm.py
Indeed, the previous computation was biased (but only when smoothing was enabled), but the primary goal was to facilitate dynamic adaptation for unregularly long iterations. Your PR should fix the issue, but we have to first check if the dynamic adaptation is OK (else we will need to fix that too :) ). |
Patch revised. |
Wow, thank's @kcwu , but you didn't need to, I intended these notes more as reminders for us tqdm devs before merging :) |
The formula of average rate should be something similar to 1/average(t for t in samples). But current implementation is similar to average(1/t for t in samples), which is incorrect. Following code can demo this problem ``` import random import time from tqdm import trange for i in trange(10000, smoothing=0.01, leave=True, miniters=1, mininterval=0, ncols=0): time.sleep(random.random() / 100) ``` Output before this fix: ``` 100% 10000/10000 [00:53<00:00, 413.96it/s] ``` After: ``` 100% 10000/10000 [00:54<00:00, 187.06it/s] ```
Google asserts copyright, even on work I do in my own time. To be clear, Google only owns the copyright of the part of my patch, not the whole project.
FYI, slightly revised the patch and add my employer to the copyright line. |
merged (and rebased) without the |
The formula of average rate should be something similar to
1/average(t for t in samples)
. But current implementation is similar toaverage(1/t for t in samples)
, which is incorrect.Following code can demo this problem
Output before this fix:
After:
10000/54=185.18 near 187.06