Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Use itertools.combinations when sweeping #81

Merged
merged 1 commit into from
May 21, 2015

Conversation

adlai
Copy link
Contributor

@adlai adlai commented May 19, 2015

>>> create_combination(['apple', 'orange', 'pear', 'orange'], 3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "lib/common.py", line 358, in create_combination
    assert len(result) == nCk(len(li), n)
AssertionError

@chris-belcher
Copy link
Collaborator

Thanks for the PR

Did this cause a crash in a real life usage?

That function is due to be deleted anyway #48

>>> import itertools
>>> [i for i in itertools.combinations(['apple', 'orange', 'pear', 'orange'], 3)]
[('apple', 'orange', 'pear'), ('apple', 'orange', 'orange'), ('apple', 'pear', 'orange'), ('orange', 'pear', 'orange'

@chris-belcher
Copy link
Collaborator

This doesn't actually work out the mathematical correct number for a list with repeated elements. If you're going to use less-than instead of equals you might as well remove the assert totally.

adlai added a commit to adlai/joinmarket that referenced this pull request May 20, 2015
adlai added a commit to adlai/joinmarket that referenced this pull request May 20, 2015
adlai added a commit to adlai/joinmarket that referenced this pull request May 20, 2015
@adlai adlai changed the title relax overly-strict assertion Use itertools.combinations when sweeping May 20, 2015
chris-belcher added a commit that referenced this pull request May 21, 2015
Use itertools.combinations when sweeping
@chris-belcher chris-belcher merged commit 9dcc04e into JoinMarket-Org:master May 21, 2015
ghtdak pushed a commit to ghtdak/joinmarket that referenced this pull request Oct 1, 2015
Use itertools.combinations when sweeping
ghtdak pushed a commit to ghtdak/joinmarket that referenced this pull request Oct 4, 2015
Use itertools.combinations when sweeping
ghtdak pushed a commit to ghtdak/joinmarket that referenced this pull request Dec 4, 2015
Use itertools.combinations when sweeping
[gitreformat yapf-ify (github/ghtdak) on Fri Dec  4 04:47:31 2015]
[from commit: 9dcc04e]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants