-
Notifications
You must be signed in to change notification settings - Fork 0
tqdm 4 #12
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
base: main
Are you sure you want to change the base?
tqdm 4 #12
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -320,8 +320,7 @@ def format_meter(n, total, elapsed, ncols=None, prefix='', ascii=False, | |||||||||||||
|
|
||||||||||||||
| # apply custom scale if necessary | ||||||||||||||
| if unit_scale and unit_scale not in (True, 1): | ||||||||||||||
| if total: | ||||||||||||||
| total *= unit_scale | ||||||||||||||
| total *= unit_scale | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical Issue: TypeError when total is None This unconditional multiplication will raise a Apply this fix to restore the conditional check: - total *= unit_scale
+ if total is not None:
+ total *= unit_scaleAlternatively, use a more defensive approach: - total *= unit_scale
+ total = total * unit_scale if total is not None else None📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| n *= unit_scale | ||||||||||||||
| if rate: | ||||||||||||||
| rate *= unit_scale # by default rate = 1 / self.avg_time | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -772,15 +772,6 @@ def test_infinite_total(): | |
| pass | ||
|
|
||
|
|
||
| @with_setup(pretest, posttest) | ||
| def test_nototal(): | ||
| """Test unknown total length""" | ||
| with closing(StringIO()) as our_file: | ||
| for i in tqdm((i for i in range(10)), file=our_file, unit_scale=10): | ||
| pass | ||
| assert "100it" in our_file.getvalue() | ||
|
|
||
|
Comment on lines
774
to
-782
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Info 🐛 BugRemoval of Issue Explanation
for i in tqdm((i for i in range(10)), file=our_file, unit_scale=10):
pass
assert "100it" in our_file.getvalue()Reply if you have any questions or let me know if I missed something. |
||
|
|
||
| @with_setup(pretest, posttest) | ||
| def test_unit(): | ||
| """Test SI unit prefix""" | ||
|
|
||
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.
🔴 Error 🐛 Bug
Always scaling
totalwithout checking forNonetriggers a TypeError whenunit_scaleis a numeric value.Issue Explanation
if total:guard before applying custom scaling.unit_scaleis a numeric value other thanTrueor1, the block always executestotal *= unit_scale.totalisNone, this multiplication raises aTypeError(unsupported operand type(s) for *=: 'NoneType' and 'int').totalasNonefor unknown or unset totals, so this scenario is valid and must be handled.blarApp/open-benchmark/tqdm_4/tqdm/_tqdm.py→format_meter(apply custom scale section).Reply if you have any questions or let me know if I missed something.
Don't forget to react with a 👍 or 👎 to the comments made by Blar to help us improve.