Skip to content

Wrong rounding for hundreds #579

@sizmailov

Description

@sizmailov

tqdm/tqdm/_tqdm.py

Lines 144 to 149 in 19cd7d7

if abs(num) < 999.95:
if abs(num) < 99.95:
if abs(num) < 9.995:
return '{0:1.2f}'.format(num) + unit + suffix
return '{0:2.1f}'.format(num) + unit + suffix
return '{0:3.0f}'.format(num) + unit + suffix

Format for hundreds is '{0:3.0f}', so numbers greater than 999.5 would be printed as 1000. This leads to trembling.

The right condition should be if abs(num) < 999.5:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions