Skip to content
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

unable to set format for numbers with unit_scale #1575

Open
daniel-baumann opened this issue Apr 27, 2024 · 0 comments
Open

unable to set format for numbers with unit_scale #1575

daniel-baumann opened this issue Apr 27, 2024 · 0 comments

Comments

@daniel-baumann
Copy link

Hi,

we've got the following bug report in Debian that I'd like to relay here (https://bugs.debian.org/1069702):

---snip---
I'm having trouble formatting numbers in progress bars when using
unit_scale. Unfortunately, there doesn't seem to be a way to do this
without overriding a lot of code.

As shown in line 565 of /usr/lib/python3/dist-packages/tqdm/std.py, the
str() method is being used to convert the floats to strings before
printing them.

Minimal working example:

import tqdm
import time

for i in tqdm.tqdm(range(7), unit_scale=1/7):
time.sleep(0.1)
print()

Output for this code:

0%| | 0.0/1.0 [00:00<?, ?it/s]
14%|████▍ | 0.14285714285714285/1.0 [00:00<00:00, 1.42it/s]
29%|█████████▏ | 0.2857142857142857/1.0 [00:00<00:00, 1.42it/s]
43%|█████████████▎ | 0.42857142857142855/1.0 [00:00<00:00, 1.42it/s]
57%|██████████████████▎ | 0.5714285714285714/1.0 [00:00<00:00, 1.42it/s]
71%|██████████████████████▊ | 0.7142857142857142/1.0 [00:00<00:00, 1.42it/s]
86%|███████████████████████████▍ | 0.8571428571428571/1.0 [00:00<00:00, 1.42it/s]
100%|███████████████████████████████████████████████| 1.0/1.0 [00:00<00:00, 1.42it/s]
---snap---

Regards,
Daniel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant