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(Iterator.product(offset arrays)) is an OffsetArray but collect (offset_array) is not #332

Open
FelixBenning opened this issue Jun 3, 2023 · 2 comments

Comments

@FelixBenning
Copy link

FelixBenning commented Jun 3, 2023

So here is a weird thing:

julia> Iterators.product(OffsetArray(rand(3), -1:1), 1:2) |> collect
3×2 OffsetArray(::Matrix{Tuple{Float64, Int64}}, -1:1, 1:2) with eltype Tuple{Float64, Int64} with indices -1:1×1:2:
 (0.892917, 1)  (0.892917, 2)
 (0.398366, 1)  (0.398366, 2)
 (0.550785, 1)  (0.550785, 2)

julia> collect(ans)
3×2 Matrix{Tuple{Float64, Int64}}:
 (0.892917, 1)  (0.892917, 2)
 (0.398366, 1)  (0.398366, 2)
 (0.550785, 1)  (0.550785, 2)

Since collect promises an Array not an AbstractArray I am thinking that the first return is wrong. But I think this should probably be consistent at least. At least I would assume that collect(collect()) == collect

@FelixBenning FelixBenning changed the title collect(Iterator.product(offset arrays)) is an OffsetArray but collect (offset_array) is not collect(Iterator.product(offset arrays)) is an OffsetArray but collect (offset_array) is not Jun 3, 2023
@jishnub
Copy link
Member

jishnub commented Jun 3, 2023

This seems like a problem with collect using similar to create the destination, instead of using an Array. Could you report this in Julia Base? That's where the fix should go to

@jishnub
Copy link
Member

jishnub commented Apr 1, 2024

Xref: JuliaLang/julia#50051

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

2 participants