Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sagemathgh-37781:
SetPartition
return empty iterator instead of err…
…oring out in degenerate cases <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Replaced the error raised by `SetPartition` in a degenerate case (see below) by an empty iterator, to match the behaviour of similar functions such as `Partitions` and `OrderedSetPartitions`. Old behaviour: ```Python sage: list( Partitions(3,length=4) ) [] sage: list( OrderedSetPartitions(range(3),4) ) [] sage: list( SetPartitions(range(3),4) ) ... ValueError: part must be <= len(set) ``` New behaviour ```Python sage: list( SetPartitions(range(3),4) ) [] ``` This solves issue sagemath#37643. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#37781 Reported by: Nolord Reviewer(s): Travis Scrimshaw
- Loading branch information