Skip to content

Commit

Permalink
refactor: revert eachindex to iterating over indices of VA.u
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Nov 29, 2023
1 parent 7bc832a commit 80cc2d8
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/vector_of_array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Base.IndexStyle(::Type{<:AbstractVectorOfArray}) = IndexCartesian()

@inline Base.length(VA::AbstractVectorOfArray) = length(VA.u)
@inline function Base.eachindex(VA::AbstractVectorOfArray)
return Iterators.flatten((CartesianIndex(i, j) for i in eachindex(arr)) for (j, arr) in enumerate(VA.u))
return eachindex(VA.u)
end
@inline Base.IteratorSize(::Type{<:AbstractVectorOfArray}) = Base.HasLength()
@inline Base.first(VA::AbstractVectorOfArray) = first(VA.u)
Expand Down Expand Up @@ -526,14 +526,8 @@ end
Base.reshape(A::VectorOfArray, dims...) = Base.reshape(Array(A), dims...)

# Need this for ODE_DEFAULT_UNSTABLE_CHECK from DiffEqBase to work properly
@inline Base.any(f, VA::AbstractVectorOfArray) = any(f, VA[i] for i in eachindex(VA))
@inline Base.all(f, VA::AbstractVectorOfArray) = all(f, VA[i] for i in eachindex(VA))
@inline function Base.any(f::Function, VA::AbstractVectorOfArray)
any(f, VA[i] for i in eachindex(VA))
end
@inline function Base.all(f::Function, VA::AbstractVectorOfArray)
all(f, VA[i] for i in eachindex(VA))
end
@inline Base.any(f, VA::AbstractVectorOfArray) = any(any(f, u) for u in VA.u)
@inline Base.all(f, VA::AbstractVectorOfArray) = all(all(f, u) for u in VA.u)

# conversion tools
vecarr_to_vectors(VA::AbstractVectorOfArray) = [VA[i, :] for i in eachindex(VA[1])]
Expand Down

0 comments on commit 80cc2d8

Please sign in to comment.