Skip to content

Commit bdbca6b

Browse files
Merge pull request #147 from sharanry/sy/fix_indexing
Fix for #146
2 parents aec3927 + 7749ba4 commit bdbca6b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/vector_of_array.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ Base.@propagate_inbounds Base.getindex(VA::AbstractVectorOfArray{T, N}, I::Colon
5959
Base.@propagate_inbounds Base.getindex(VA::AbstractDiffEqArray{T, N}, I::Colon) where {T, N} = VA.u[I]
6060
Base.@propagate_inbounds Base.getindex(VA::AbstractVectorOfArray{T, N}, I::AbstractArray{Int}) where {T, N} = VectorOfArray(VA.u[I])
6161
Base.@propagate_inbounds Base.getindex(VA::AbstractDiffEqArray{T, N}, I::AbstractArray{Int}) where {T, N} = DiffEqArray(VA.u[I],VA.t[I])
62+
Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},
63+
I::Union{Int,AbstractArray{Int},CartesianIndex,Colon,BitArray,AbstractArray{Bool}}...) where {T, N}
64+
RecursiveArrayTools.VectorOfArray(A.u)[I...]
65+
end
66+
Base.@propagate_inbounds Base.getindex(A::AbstractDiffEqArray{T, N}, i::Int,::Colon) where {T, N} = [A.u[j][i] for j in 1:length(A)]
67+
Base.@propagate_inbounds Base.getindex(A::AbstractDiffEqArray{T, N}, ::Colon,i::Int) where {T, N} = A.u[i]
68+
Base.@propagate_inbounds Base.getindex(A::AbstractDiffEqArray{T, N}, i::Int,II::AbstractArray{Int}) where {T, N} = [A.u[j][i] for j in II]
6269
Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym) where {T, N}
6370
if issymbollike(sym) && A.syms !== nothing
6471
i = findfirst(isequal(Symbol(sym)),A.syms)
@@ -90,7 +97,7 @@ Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym
9097
observed(A,sym,args...)
9198
end
9299
else
93-
Base.getindex.(A.u, args...)
100+
Base.getindex.(A.u, i, args...)
94101
end
95102
end
96103
Base.@propagate_inbounds Base.getindex(A::AbstractDiffEqArray{T, N}, I::Int...) where {T, N} = A.u[I[end]][Base.front(I)...]

0 commit comments

Comments
 (0)