-
Notifications
You must be signed in to change notification settings - Fork 59
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
Fix integer partitions #82
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #82 +/- ##
===========================================
+ Coverage 75.51% 94.23% +18.72%
===========================================
Files 7 7
Lines 637 503 -134
===========================================
- Hits 481 474 -7
+ Misses 156 29 -127
Continue to review full report at Codecov.
|
function Base.iterate(p::IntegerPartitions, xs = Int[]) | ||
function Base.iterate(p::IntegerPartitions) | ||
p.n == 0 && return (Int[], Int[]) | ||
return iterate(p, Int[]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return iterate(p, Int[]) | |
return iterate(p, Int[]) |
Indentation
@@ -17,7 +17,12 @@ end | |||
Base.length(p::IntegerPartitions) = npartitions(p.n) | |||
Base.eltype(p::IntegerPartitions) = Vector{Int} | |||
|
|||
function Base.iterate(p::IntegerPartitions, xs = Int[]) | |||
function Base.iterate(p::IntegerPartitions) | |||
p.n == 0 && return (Int[], Int[]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p.n == 0 && return (Int[], Int[]) | |
p.n == 0 && return (Int[], Int[]) |
What do we do with this? Can we make this non-breaking? |
@mschauer sorry this was lost in my github notifications. To answer your question, I don't know how to make it non-breaking. Not sure why So, seems to me this should be a breaking change to remove the |
I would opt for deprecate it and keep it doing what it did before instead of collecting |
Agreed. |
This would close #79 #80 and #81.
Solution is due to @simonschoelly.
Note that
integer_partitions
is still implemented, but now justcollect
spartitions(n::Int)
. However, this implementation now returns the partitions in reverse order as before, so this would be a breaking change! Probably best to just removeinteger_partitions
Also,
partitions(0)
now correctly returns the set containing the empty set and is the same as what's returned byinteger_partitions(0)
, which was not the case before.