-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Hi all, first of all thank you for the effort you've put into developing this useful tool.
I was trying to reset a progress bar to its initial state, and I found what I think might be a bug. Resetting the progress bar state to a previous value has been discussed here: #545 #432 #374 . The consensus seems to be that to reset a progress bar, you need to explicitly set its n
attribute and then refresh manually:
pbar.n = 0;
pbar.refresh()
However I've found that, even doing this, the progress bar will not update correctly until its counter reaches the previous value again.
Here is a MWE:
from tqdm import tqdm
import time
total = 100
pbar = tqdm(total=total)
for i in range(10):
pbar.update()
time.sleep(.1)
pbar.n = 0
pbar.refresh()
for i in range(total):
pbar.update()
time.sleep(.1)
Expected behavior:
- Bar grows from 0% to 10%
- Bar resets to 0%
- Bar grows from 0% to 100%
Actual behavior:
- Bar grows from 0% to 10%
- Bar resets to 0%
- Bar stays at 0% for about the same time that it would take to reach 10%
- Bar goes instantly to 10%, and then grows from 10% to 100%
The issue doesn't present itself if I manually refresh after each update in the second loop; but I assume this is a work-around and should not be necessary (?)
system: Debian GNU/Linux 9.4 (stretch)
python: 3.6.5
tqdm: 4.19.8