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

collect behavior does not match iteration for zip of iterators with unequal lengths #17928

Closed
Keno opened this issue Aug 9, 2016 · 5 comments
Milestone

Comments

@Keno
Copy link
Member

Keno commented Aug 9, 2016

julia> collect(zip([1,2,3],[1,2],[1,2,3]))
ERROR: DimensionMismatch("dimensions must match")
 in promote_shape(::Tuple{Base.OneTo{Int64}}, ::Tuple{Base.OneTo{Int64}}) at ./operators.jl:401
 in indices(::Base.Zip2{Array{Int64,1},Array{Int64,1}}) at ./iterator.jl:91
 in _similar_for(::UnitRange{Int64}, ::Type{T}, ::Zip{Array{Int64,1},Base.Zip2{Array{Int64,1},Array{Int64,1}}}, ::Base.HasShape) at ./array.jl:260
 in collect(::Zip{Array{Int64,1},Base.Zip2{Array{Int64,1},Array{Int64,1}}}) at ./array.jl:270

julia> for x in zip([1,2,3],[1,2],[1,2,3])
       println(x)
       end
(1,1,1)
(2,2,2)
@kshyatt
Copy link
Contributor

kshyatt commented Sep 14, 2016

This is still a problem on latest master.

@StefanKarpinski StefanKarpinski added this to the 0.6.0 milestone Sep 14, 2016
@samoconnor
Copy link
Contributor

Is this a bug in zip or a bug in collect ?
collect(zip([1,2,3],[1,2],[1,2,3])) used to "work" in 0.4.

@JeffBezanson JeffBezanson modified the milestones: 1.0, 0.6.0 Jan 3, 2017
@StefanKarpinski
Copy link
Member

Closing in favor of #20499.

@schlichtanders
Copy link

this is still an issue in julia 1.1.1

to repeat #20499 (comment)
zip still behaves unexpectedly...

julia> collect(zip(1:3, 2:5))
ERROR: DimensionMismatch("dimensions must match")
Stacktrace:
 [1] promote_shape at .\indices.jl:154 [inlined]
 [2] _promote_shape at .\iterators.jl:317 [inlined]
 [3] axes at .\iterators.jl:316 [inlined]
 [4] _similar_for at .\array.jl:519 [inlined]
 [5] _collect(::UnitRange{Int64}, ::Base.Iterators.Zip{Tuple{UnitRange{Int64},UnitRange{Int64}}}, ::Base.HasEltype, ::Base.HasShape{1}) at .\array.jl:550
 [6] collect(::Base.Iterators.Zip{Tuple{UnitRange{Int64},UnitRange{Int64}}}) at .\array.jl:544
 [7] top-level scope at none:0

julia> for i in zip(1:3, 2:5)
          @show i
       end
i = (1, 2)
i = (2, 3)
i = (3, 4)

I was really surprised seeing that this issue is already 3 years old

@schlichtanders
Copy link

schlichtanders commented Jul 31, 2019

How would one rewrite collect(zip(1:3, 2:5)) in julia 1.x to work?

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

No branches or pull requests

6 participants