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

Return Vector when creating similar VectorOfArray with new length #401

Closed
ErikQQY opened this issue Sep 8, 2024 · 1 comment · Fixed by #402
Closed

Return Vector when creating similar VectorOfArray with new length #401

ErikQQY opened this issue Sep 8, 2024 · 1 comment · Fixed by #402
Labels

Comments

@ErikQQY
Copy link
Member

ErikQQY commented Sep 8, 2024

Question❓

Not sure if it's intended to behave like this or just a bug. When creating a similar array of VectorOfArray with a new length, wouldn't it be more intuitive to get VectorOfArray instead of just Vector? Since when we are doing the same for Vector{Vector}, we would end up getting Vector{Vector}.

julia> a = [rand(2) for _ in 1:3]
3-element Vector{Vector{Float64}}:
 [0.22672429007808392, 0.006545325869979246]
 [0.45202853665794596, 0.007153478061376006]
 [0.01950886804209273, 0.7556357057552318]

julia> va = VectorOfArray(a)
VectorOfArray{Float64,2}:
3-element Vector{Vector{Float64}}:
 [0.22672429007808392, 0.006545325869979246]
 [0.45202853665794596, 0.007153478061376006]
 [0.01950886804209273, 0.7556357057552318]

julia> similar(va, 4)
4-element Vector{Float64}:
 4.0e-323
 6.95219884198975e-310
 6.9522006963596e-310
 6.9521976152192e-310

julia> similar(a, 4)
4-element Vector{Vector{Float64}}:
 #undef
 #undef
 #undef
 #undef
@ChrisRackauckas
Copy link
Member

That's not intended. It should be a VectorOfArray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants