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

set_description takes no effect until .update() is called #317

Closed
gwerbin opened this issue Dec 5, 2016 · 6 comments
Closed

set_description takes no effect until .update() is called #317

gwerbin opened this issue Dec 5, 2016 · 6 comments
Assignees
Labels
question/docs ‽ Documentation clarification candidate

Comments

@gwerbin
Copy link

gwerbin commented Dec 5, 2016

Expected behavior: set_description() takes effect immediately when called

Actual behavior: set_description() takes effect only when .update() is called.

Steps to reproduce

import time

with tqdm(total=10, miniters=1, mininterval=0) as progress:
    for i in range(10):
        progress.set_description("step " + str(i + 1))
        time.sleep(0.5)
        progress.update()

Python version 3.5.2, TQDM version 4.10.0-10bd71

@lrq3000
Copy link
Member

lrq3000 commented Dec 5, 2016

Hello @gwerbin,

You can use progress.refresh() to force the display refresh. Maybe we should force the refresh inside set_description(), we didn't give this much of a thought to be honest. The only thing is that refresh() is expensive because it then forces your bar display twice per iteration...

What you could rather do to be more computationally effective while having the same result would be to set the first iteration's description at tqdm initialization and move the call to set_description() to the end of the loop:

import time

with tqdm(total=10, miniters=1, mininterval=0, desc="step 0") as progress:
    for i in range(10):
        time.sleep(0.5)
        progress.set_description("step " + str(i + 1))
        progress.update()

@lrq3000 lrq3000 added the question/docs ‽ Documentation clarification candidate label Dec 5, 2016
@gwerbin
Copy link
Author

gwerbin commented Dec 6, 2016

@lrq3000 thanks, that makes sense. Maybe we can just call this a documentation issue then. There should be a "TQDM Cookbook" if there isn't already.

@gwerbin gwerbin changed the title set_description takes no effect until .update(0) is called set_description takes no effect until .update() is called Dec 8, 2016
@ericfrederich
Copy link

I would consider this a bug. Just add a call to update() or refresh() within set_description().

It's interesting to note that the docs have this snippet of code:

pbar = tqdm(["a", "b", "c", "d"])
for char in pbar:
    pbar.set_description("Processing %s" % char)

You'll never see "Processing a", so it should say "Processed" instead of "Processing"

@casperdcl casperdcl self-assigned this Apr 5, 2017
casperdcl added a commit that referenced this issue May 1, 2017
- addresses #317
- also minor documentation updates
casperdcl added a commit that referenced this issue May 4, 2017
- addresses #317
- also minor documentation updates
@olalonde
Copy link

This seems like a bug.. .refresh() doesn't fix the issue here.

@ChrisPVille
Copy link

I've also run into this issue. I've moved the progress bar into its own worker thread, and I still can't seem to get the postfix to update with .refresh() or .update(0). It usually does draw correctly after .update(1) or larger, but this obviously skews the results upward.

casperdcl added a commit that referenced this issue Sep 9, 2017
- addresses #317
- also minor documentation updates
@ericfrederich
Copy link

Thanks @casperdcl ... I was surprised to see how far back this issue went. I agree though, perhaps refresh should be set to False

casperdcl added a commit that referenced this issue Oct 4, 2017
fixes #459
bug introduced in #317
casperdcl added a commit that referenced this issue Oct 4, 2017
fixes #459
bug introduced in #317
@casperdcl casperdcl mentioned this issue Oct 5, 2017
5 tasks
casperdcl added a commit that referenced this issue Oct 5, 2017
fixes #459
bug introduced in #317
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question/docs ‽ Documentation clarification candidate
Projects
None yet
Development

No branches or pull requests

6 participants