Skip to content

Commit

Permalink
Fix similar for VectorOfArray when both type and dims are specified
Browse files Browse the repository at this point in the history
Signed-off-by: ErikQQY <[email protected]>
  • Loading branch information
ErikQQY committed Sep 11, 2024
1 parent 8ff79f5 commit c4e0076
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/vector_of_array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ end
VectorOfArray([similar(VA[:, i], T) for i in eachindex(VA.u)])
end

@inline function Base.similar(VA::VectorOfArray, dims::N) where {N}
@inline function Base.similar(VA::VectorOfArray, dims::N) where {N <: Number}
l = length(VA)
if dims <= l
VectorOfArray([similar(VA[:, i]) for i in 1:l])
Expand All @@ -744,15 +744,6 @@ end
end
end

@inline function Base.similar(VA::VectorOfArray, ::Type{T}, dims::N) where {N, T}
l = length(VA)
if dims <= l
VectorOfArray([similar(VA[:, i], T) for i in 1:l])
else
VectorOfArray([[similar(VA[:, i], T) for i in 1:l]; [similar(VA.u[end], T) for _ in (l+1):dims]])
end
end

@inline function Base.similar(VA::VectorOfArray{T, N, AT},
dims::Tuple) where {T, N, AT <: AbstractArray{<:AbstractArray{T}}}
VectorOfArray(similar(VA.u, dims))
Expand Down

0 comments on commit c4e0076

Please sign in to comment.