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

Manual muti-line tqdm showing incorrect status #695

Closed
garrettreid opened this issue Mar 9, 2019 · 1 comment
Closed

Manual muti-line tqdm showing incorrect status #695

garrettreid opened this issue Mar 9, 2019 · 1 comment

Comments

@garrettreid
Copy link

I'm having issues with using tqdm in manual mode with multiple progress bars. One bar (the inner loop/position=1) behaves correctly. The other (outer loop/position=0) behaves incorrectly. While my code should be stepping by 10% each time, I instead see 0%, 10%, 30%, 60%, 100%.

render1552162679754-min

Here's the code, reduced as much as I can. It's just two loops. This implementation could work with iterable-based tqdm, but my end goal can't.

#!/usr/bin/env python
from time import sleep
from tqdm import tqdm

# Upper bar, outer loop
bar1 = tqdm(total=10, position=0, miniters=1)

for i in range(10):
    bar1.update(i)

    # Lower bar, inner loop
    bar2 = tqdm(total=10, position=1, miniters=1)
    for j in range(10):
        bar2.update(j)
        sleep(0.1)
    bar2.close()
bar1.close()

My system information:

import tqdm, sys
print(tqdm.__version__, sys.version, sys.platform)

4.31.1 3.7.2 (default, Feb 13 2019, 00:32:38)
[Clang 10.0.0 (clang-1000.11.45.5)] darwin

@garrettreid
Copy link
Author

Whoops. As things things were probably destined to go with a first github issue: I'm using the code wrong :)

tqdm.update() takes a value by which to increase the progress bar, not a total value to update to. After changing my code from bar1.update(i) to bar1.update(1) (and the equivalent for bar2), everything is working as expected.

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