-
Notifications
You must be signed in to change notification settings - Fork 301
Add nth_combination_with_replacement #704
New issue
Have a question about this project? Sign up for a free GitHub ac 8000 count 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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This includes type defenitions and tests for the new function.
From test_recipes -> test_more.
bbayles
approved these changes
Apr 3, 2023
lengau
referenced
this pull request
in canonical/charmcraft
Jul 25, 2023
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [more-itertools](https://togithub.com/more-itertools/more-itertools) | `==9.1.0` -> `==10.0.0` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>more-itertools/more-itertools (more-itertools)</summary> ### [`v10.0.0`](https://togithub.com/more-itertools/more-itertools/releases/tag/v10.0.0): Version 10.0.0 [Compare Source](https://togithub.com/more-itertools/more-itertools/compare/v9.1.0...v10.0.0) ##### What's Changed - Update recipes.iter_index to match CPython PR 102360 by [@​bbayles](https://togithub.com/bbayles) in [https://github.com/more-itertools/more-itertools/pull/690](https://togithub.com/more-itertools/more-itertools/pull/690) - fixup - add missing commas to the readme function table by [@​lonnen](https://togithub.com/lonnen) in [https://github.com/more-itertools/more-itertools/pull/692](https://togithub.com/more-itertools/more-itertools/pull/692) - fixup remove 3.6 from tox by [@​lonnen](https://togithub.com/lonnen) in [https://github.com/more-itertools/more-itertools/pull/693](https://togithub.com/more-itertools/more-itertools/pull/693) - seekable: Add relative_seek by [@​karlb](https://togithub.com/karlb) in [https://github.com/more-itertools/more-itertools/pull/694](https://togithub.com/more-itertools/more-itertools/pull/694) - Optimize \_chunked_even_finite() by [@​elliotwutingfeng](https://togithub.com/elliotwutingfeng) in [https://github.com/more-itertools/more-itertools/pull/699](https://togithub.com/more-itertools/more-itertools/pull/699) - Indexing of combinations with replacement by [@​Schoyen](https://togithub.com/Schoyen) in [https://github.com/more-itertools/more-itertools/pull/689](https://togithub.com/more-itertools/more-itertools/pull/689) - Add notes for transposing empty inputs by [@​XuehaiPan](https://togithub.com/XuehaiPan) in [https://github.com/more-itertools/more-itertools/pull/700](https://togithub.com/more-itertools/more-itertools/pull/700) - Add the polynomial_eval recipe by [@​bbayles](https://togithub.com/bbayles) in [https://github.com/more-itertools/more-itertools/pull/703](https://togithub.com/more-itertools/more-itertools/pull/703) - Add nth_combination_with_replacement by [@​Schoyen](https://togithub.com/Schoyen) in [https://github.com/more-itertools/more-itertools/pull/704](https://togithub.com/more-itertools/more-itertools/pull/704) - Add sum_of_squares, sync with itertools by [@​bbayles](https://togithub.com/bbayles) in [https://github.com/more-itertools/more-itertools/pull/706](https://togithub.com/more-itertools/more-itertools/pull/706) - Issue [#​707](https://togithub.com/more-itertools/more-itertools/issues/707): fix `iterate()` to enable `func` to raise StopIteration + 3 unittests by [@​jrebiffe](https://togithub.com/jrebiffe) in [https://github.com/more-itertools/more-itertools/pull/708](https://togithub.com/more-itertools/more-itertools/pull/708) - Update polynomial_from roots and convolve by [@​bbayles](https://togithub.com/bbayles) in [https://github.com/more-itertools/more-itertools/pull/709](https://togithub.com/more-itertools/more-itertools/pull/709) - Issue [#​677](https://togithub.com/more-itertools/more-itertools/issues/677): Improve `partition` by [@​pochmann](https://togithub.com/pochmann) in [https://github.com/more-itertools/more-itertools/pull/710](https://togithub.com/more-itertools/more-itertools/pull/710) - Issue [#​713](https://togithub.com/more-itertools/more-itertools/issues/713): Fix `partial_product` (also simplify and clean up) by [@​pochmann](https://togithub.com/pochmann) in [https://github.com/more-itertools/more-itertools/pull/714](https://togithub.com/more-itertools/more-itertools/pull/714) - Issue [#​711](https://togithub.com/more-itertools/more-itertools/issues/711): Optimize `pairwise` by [@​pochmann](https://togithub.com/pochmann) in [https://github.com/more-itertools/more-itertools/pull/712](https://togithub.com/more-itertools/more-itertools/pull/712) - Issue [#​715](https://togithub.com/more-itertools/more-itertools/issues/715): Simplify/optimize `partial_product` by [@​pochmann](https://togithub.com/pochmann) in [https://github.com/more-itertools/more-itertools/pull/716](https://togithub.com/more-itertools/more-itertools/pull/716) - Issue [#​717](https://togithub.com/more-itertools/more-itertools/issues/717): Improve `duplicates_justseen` by [@​pochmann](https://togithub.com/pochmann) in [https://github.com/more-itertools/more-itertools/pull/718](https://togithub.com/more-itertools/more-itertools/pull/718) - Fix unique_in_window to match described behavior by [@​elliotwutingfeng](https://togithub.com/elliotwutingfeng) in [https://github.com/more-itertools/more-itertools/pull/720](https://togithub.com/more-itertools/more-itertools/pull/720) - Add polynomial_derivative recipe by [@​bbayles](https://togithub.com/bbayles) in [https://github.com/more-itertools/more-itertools/pull/723](https://togithub.com/more-itertools/more-itertools/pull/723) - Update recipes with CPython PRs: 105403 and 106371 by [@​bbayles](https://togithub.com/bbayles) in [https://github.com/more-itertools/more-itertools/pull/731](https://togithub.com/more-itertools/more-itertools/pull/731) - Changes for version 10.0.0 by [@​bbayles](https://togithub.com/bbayles) in [https://github.com/more-itertools/more-itertools/pull/734](https://togithub.com/more-itertools/more-itertools/pull/734) - Delay computation of numeric_range len until needed by [@​eltoder](https://togithub.com/eltoder) in [https://github.com/more-itertools/more-itertools/pull/674](https://togithub.com/more-itertools/more-itertools/pull/674) ##### New Contributors - [@​karlb](https://togithub.com/karlb) made their first contribution in [https://github.com/more-itertools/more-itertools/pull/694](https://togithub.com/more-itertools/more-itertools/pull/694) - [@​elliotwutingfeng](https://togithub.com/elliotwutingfeng) made their first contribution in [https://github.com/more-itertools/more-itertools/pull/699](https://togithub.com/more-itertools/more-itertools/pull/699) - [@​Schoyen](https://togithub.com/Schoyen) made their first contribution in [https://github.com/more-itertools/more-itertools/pull/689](https://togithub.com/more-itertools/more-itertools/pull/689) - [@​XuehaiPan](https://togithub.com/XuehaiPan) made their first contribution in [https://github.com/more-itertools/more-itertools/pull/700](https://togithub.com/more-itertools/more-itertools/pull/700) - [@​jrebiffe](https://togithub.com/jrebiffe) made their first contribution in [https://github.com/more-itertools/more-itertools/pull/708](https://togithub.com/more-itertools/more-itertools/pull/708) - [@​pochmann](https://togithub.com/pochmann) made their first contribution in [https://github.com/more-itertools/more-itertools/pull/710](https://togithub.com/more-itertools/more-itertools/pull/710) - [@​eltoder](https://togithub.com/eltoder) made their first contribution in [https://github.com/more-itertools/more-itertools/pull/674](https://togithub.com/more-itertools/more-itertools/pull/674) **Full Changelog**: more-itertools/more-itertools@v9.1.1...v10.0.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "every weekend" in timezone Etc/UTC, Automerge - "before 07:00" in timezone Etc/UTC. 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/canonical/charmcraft). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMTEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue reference
This pull request closes #684.
Changes
This pull request implements the
nth_combination_with_replacement
with tests and doc strings. The function is an analog tonth_combination
andnth_permutation
, but foritertools.combinations_with_replacement
. I have slightly modified the code by @lukemarris from #684 (comment). The main change is to drop then_choose_r
-function and instead usemath.factorial
to compute the combinations.