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

Reflect the length hint in the total of the progress bar #1426

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bartbroere
Copy link

Before this pull request, if self.iterable had a length hint, it would be reflected in the length of the tqdm object, but the progress bar would not show it as a total.

Reproduction:

import string

from more_itertools import consume
from tqdm import tqdm


class ExampleGenerator:

    def __iter__(self):
        for letter in string.ascii_letters:
            yield letter

    def __length_hint__(self):
        return len(string.ascii_letters)


consume(tqdm(ExampleGenerator()))

Output before this PR:

52it [00:00, 1703936.00it/s]

Output after this PR:

100%|██████████| 52/52 [00:00<00:00, 1603704.47it/s]

Related issues: #1068 #228 #1132

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

Successfully merging this pull request may close these issues.

None yet

1 participant