Skip to content

Commit 7749ba4

Browse files
committed
Handle ambiguities
1 parent 88295d9 commit 7749ba4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/vector_of_array.jl

Lines changed: 24 additions & 0 deletions
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)
@@ -76,6 +83,23 @@ Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym
7683
Base.getindex.(A.u, i)
7784
end
7885
end
86+
Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym,args...) where {T, N}
87+
if issymbollike(sym) && A.syms !== nothing
88+
i = findfirst(isequal(Symbol(sym)),A.syms)
89+
else
90+
i = sym
91+
end
92+
93+
if i === nothing
94+
if issymbollike(i) && A.indepsym !== nothing && Symbol(i) == A.indepsym
95+
A.t[args...]
96+
else
97+
observed(A,sym,args...)
98+
end
99+
else
100+
Base.getindex.(A.u, i, args...)
101+
end
102+
end
79103
Base.@propagate_inbounds Base.getindex(A::AbstractDiffEqArray{T, N}, I::Int...) where {T, N} = A.u[I[end]][Base.front(I)...]
80104
Base.@propagate_inbounds Base.getindex(A::AbstractDiffEqArray{T, N}, i::Int) where {T, N} = A.u[i]
81105
function observed(A::AbstractDiffEqArray{T, N},sym,i::Int) where {T, N}

0 commit comments

Comments
 (0)