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

add keyword 'repeat' for tqdm.contrib.itertools.product #1552

Closed
wants to merge 1 commit into from

Conversation

unickname3
Copy link

At now keyword 'repeat' don't work in tqdm.contrib.itertools.product()

From itertools docs:

itertools.product(*iterables, repeat=1)
....
To compute the product of an iterable with itself, specify the number of repetitions with the optional repeat keyword argument. For example, product(A, repeat=4) means the same as product(A, A, A, A).

There is my solution for this problem.

@bartbroere
Copy link

Hi, I made a similar PR some time ago: #1428. It's still open.

I don't care really which one of these gets merged, but now they're both linked at least.

@@ -29,7 +29,7 @@ def product(*iterables, **tqdm_kwargs):
total *= i

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from some minor differences (in the tests for example), I only found one difference that seems to matter. I believe that the influence of actually using the repeat parameter is not yet reflected in the total in your version. On my branch I do this to get a correct total:

Suggested change
total *= i
total *= i
total = total ** repeat

Without this fix I believe the progress bar will exceed 100% (after which it just starts displaying the amount of iterations).

@unickname3 unickname3 closed this by deleting the head repository Apr 10, 2024
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

2 participants