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

integer and set partitions #297

Merged
merged 5 commits into from
Jul 13, 2019
Merged

integer and set partitions #297

merged 5 commits into from
Jul 13, 2019

Conversation

ktbarrett
Copy link
Contributor

Implements lexically-ordered integer and set partitions generators. The generators can generate only k-partitions, or if no k is given, it will generate all number of partitions.

@ktbarrett ktbarrett mentioned this pull request Jul 11, 2019
Copy link
Collaborator

@bbayles bbayles left a comment

Choose a reason for hiding this comment

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

Many thanks for this PR.

I think the integer_partitions I would rather leave out, since it only applies to iterables of integers. I have used a similar algorithm (this one), but I think it's slightly outside the scope of more-itertools.

set_partitions looks like a good inclusion.

Could I ask you to (1) drop integer_partitions, (2) add tests for set_partitions?

Thanks again.

def set_partitions(iterable, k=None):
"""
Generates k set partitions of iterable, or all partitions if k is not given
A set partition is a wasy to split a set into unique subsets that when
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
A set partition is a wasy to split a set into unique subsets that when
A set partition is a way to split a set into unique subsets that when

@bbayles bbayles merged commit 57b3798 into more-itertools:master Jul 13, 2019
@bbayles
Copy link
Collaborator

bbayles commented Jul 13, 2019

Closes #296. Many thanks!

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