JuliaCollections / JuliaCollections/IterTools.jl
Collect subsets of tuple
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 160
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
Is this a bug in IterTools?
julia> using IterTools
julia> collect(subsets((0,2,6), 2))
ERROR: MethodError: Cannot `convert` an object of type Tuple{Int64,Int64} to an object of type Array{Int64,1}
...
Stacktrace:
[1] setindex!(::Array{Array{Int64,1},1}, ::Tuple{Int64,Int64}, ::Int64) at ./array.jl:767
[2] copyto!(::Array{Array{Int64,1},1}, ::IterTools.Binomial{Tuple{Int64,Int64,Int64}}) at ./abstractarray.jl:671
[3] _collect at ./array.jl:550 [inlined]
[4] collect(::IterTools.Binomial{Tuple{Int64,Int64,Int64}}) at ./array.jl:544
[5] top-level scope at none:0
This works though:
julia> collect(x for x in subsets((0,2,6), 2))
3-element Array{Tuple{Int64,Int64},1}:
(0, 2)
(0, 6)
(2, 6)
Julia 1.1
IterTools 1.3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing collect(subsets((0,2,6), 2)) with Julia 1.1 and IterTools 1.3, then compare it with the generator-based collection shown in the issue. Trace the subsets iterator and collection behavior until the tuple-to-array conversion failure is located; done means direct collection returns the expected three tuples without the MethodError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100