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

Use Base.Iterators.flatten instead of Iterators.chain #50

Closed
wants to merge 1 commit into from
Closed

Conversation

musm
Copy link
Contributor

@musm musm commented Jun 20, 2017

No description provided.

@@ -1,7 +1,7 @@
using Combinatorics
using Base.Test

@test [combinations([])...] == []
@test_skip [combinations([])...] == []
Copy link
Contributor Author

@musm musm Jun 20, 2017

Choose a reason for hiding this comment

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

Does this really make sense? I.e. should [combinations([])...] == [] actually work instead of just throwing an Argument error?

hmm I see that

julia> combinations([],0) |>collect
0-element Array{Array{Any,1},1}

Copy link
Member

Choose a reason for hiding this comment

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

yeah I am not sure this really should work. There aren't no combinations of nothing, it's just undefined? I guess what really matters is whether completeness here really matters. It doesn't seem useful, and I'd rather see an error here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#46 might be related?

Copy link
Contributor

Choose a reason for hiding this comment

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

The way it was implemented was consistently with the fact that $C^0_0 = 1$

julia> binomial(0,0)
1

julia> length(combinations([], 0))
1

@musm musm mentioned this pull request Jun 20, 2017
@codecov-io
Copy link

codecov-io commented Jun 20, 2017

Codecov Report

Merging #50 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #50   +/-   ##
=======================================
  Coverage   96.96%   96.96%           
=======================================
  Files           6        6           
  Lines         594      594           
=======================================
  Hits          576      576           
  Misses         18       18
Impacted Files Coverage Δ
src/combinations.jl 84.48% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dca8530...957c6de. Read the comment docs.

@@ -1,7 +1,7 @@
using Combinatorics
using Base.Test

@test [combinations([])...] == []
@test_skip [combinations([])...] == []
Copy link
Member

Choose a reason for hiding this comment

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

yeah I am not sure this really should work. There aren't no combinations of nothing, it's just undefined? I guess what really matters is whether completeness here really matters. It doesn't seem useful, and I'd rather see an error here.

@ChrisRackauckas
Copy link
Member

LGTM. But probably need other eyes since I am not a contributor here. This change avoids a temporary and should be strictly better anyways.

@ChrisRackauckas
Copy link
Member

@jiahao is it okay if I ping you here? These Iterators failures that the current setup has is very breaking. DiffEq v0.6 is fixed if this goes through (along with Roots.jl, though Bio.jl will still be broken since it has a direct dep to iterators). I would be willing to do the tagging after this if that's okay?

JuliaLang/julia#21969

@musm
Copy link
Contributor Author

musm commented Jun 20, 2017

also maybe @randy3k @andrioni

@randy3k
Copy link
Contributor

randy3k commented Jun 21, 2017

In a strictly mathematical sense, the collection of all subsets should include the empty set.

flatten(combinations(a,k) for k = 0:length(a))

In this way, the argument will always have at least one member. Though, it may not be practical.

@musm musm closed this Jun 25, 2017
@musm musm deleted the rev branch June 25, 2017 16:56
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.

4 participants