Skip to content

Commit 59d1150

Browse files
committed
Add checks in getindex(::AbstractDiffEqArray)
1 parent 59bea76 commit 59d1150

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/vector_of_array.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,14 @@ Base.@propagate_inbounds Base.getindex(VA::AbstractVectorOfArray{T, N}, I::Colon
5959
Base.@propagate_inbounds Base.getindex(VA::AbstractVectorOfArray{T, N}, I::AbstractArray{Int}) where {T, N} = VectorOfArray(VA.u[I])
6060
Base.@propagate_inbounds Base.getindex(VA::AbstractDiffEqArray{T, N}, I::AbstractArray{Int}) where {T, N} = DiffEqArray(VA.u[I],VA.t[I])
6161
Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym) where {T, N}
62-
if issymbollike(sym)
62+
if issymbollike(sym) && A.syms !== nothing
6363
i = findfirst(isequal(Symbol(sym)),A.syms)
6464
else
6565
i = sym
6666
end
6767

6868
if i === nothing
69-
# TODO: Check if system actually has a indepsym
70-
if issymbollike(i) && Symbol(i) == A.indepsym
69+
if issymbollike(i) && A.indepsym !== nothing && Symbol(i) == A.indepsym
7170
A.t
7271
else
7372
observed(A,sym,:)
@@ -77,15 +76,14 @@ Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym
7776
end
7877
end
7978
Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym,args...) where {T, N}
80-
if issymbollike(sym)
79+
if issymbollike(sym) && A.syms !== nothing
8180
i = findfirst(isequal(Symbol(sym)),A.syms)
8281
else
8382
i = sym
8483
end
8584

8685
if i === nothing
87-
# TODO: Check if system actually has a indepsym
88-
if issymbollike(i) && Symbol(i) == A.indepsym
86+
if issymbollike(i) && A.indepsym !== nothing && Symbol(i) == A.indepsym
8987
A.t[args...]
9088
else
9189
observed(A,sym,args...)

0 commit comments

Comments
 (0)