From cf003a34387fe42ae4d2a1bb8fad5ed28c12a751 Mon Sep 17 00:00:00 2001 From: Sharan Yalburgi Date: Mon, 12 Jul 2021 16:51:32 +0530 Subject: [PATCH 1/4] Remove unreachable code --- src/vector_of_array.jl | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/vector_of_array.jl b/src/vector_of_array.jl index 8b7172d4..ec037cef 100644 --- a/src/vector_of_array.jl +++ b/src/vector_of_array.jl @@ -72,11 +72,7 @@ Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym end if i === nothing - if issymbollike(i) && A.indepsym !== nothing && Symbol(i) == A.indepsym - A.t - else - observed(A,sym,:) - end + observed(A,sym,:) else Base.getindex.(A.u, i) end @@ -89,11 +85,7 @@ Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym end if i === nothing - if issymbollike(i) && A.indepsym !== nothing && Symbol(i) == A.indepsym - A.t[args...] - else - observed(A,sym,args...) - end + observed(A,sym,args...) else Base.getindex.(A.u, i, args...) end From 99ed19b03453204f6196d306943c33aa596f2e01 Mon Sep 17 00:00:00 2001 From: Sharan Yalburgi Date: Mon, 12 Jul 2021 19:40:25 +0530 Subject: [PATCH 2/4] Cover indepsym indexing case --- src/vector_of_array.jl | 12 ++++++++++-- test/downstream/symbol_indexing.jl | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/vector_of_array.jl b/src/vector_of_array.jl index ec037cef..e32d4ddd 100644 --- a/src/vector_of_array.jl +++ b/src/vector_of_array.jl @@ -72,7 +72,11 @@ Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym end if i === nothing - observed(A,sym,:) + if issymbollike(sym) && A.indepsym !== nothing && Symbol(sym) == A.indepsym + A.t + else + observed(A,sym,:) + end else Base.getindex.(A.u, i) end @@ -85,7 +89,11 @@ Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym end if i === nothing - observed(A,sym,args...) + if issymbollike(sym) && A.indepsym !== nothing && Symbol(sym) == A.indepsym + A.t[args...] + else + observed(A,sym,args...) + end else Base.getindex.(A.u, i, args...) end diff --git a/test/downstream/symbol_indexing.jl b/test/downstream/symbol_indexing.jl index ecabac6a..7f32198e 100644 --- a/test/downstream/symbol_indexing.jl +++ b/test/downstream/symbol_indexing.jl @@ -21,3 +21,5 @@ sol_new = DiffEqArray( ) @test sol_new[RHS] ≈ (1 .- sol_new[x])./3.0 +@test sol_new[t] ≈ sol_new.t +@test sol_new[t, 1:5] ≈ sol_new.t[1:5] \ No newline at end of file From 1b0715babce32368a355d802cfd1d046cab3b02e Mon Sep 17 00:00:00 2001 From: Sharan Yalburgi Date: Mon, 12 Jul 2021 20:51:27 +0530 Subject: [PATCH 3/4] Replace `===` with `==` --- src/vector_of_array.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vector_of_array.jl b/src/vector_of_array.jl index e32d4ddd..1609eba2 100644 --- a/src/vector_of_array.jl +++ b/src/vector_of_array.jl @@ -71,7 +71,7 @@ Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym i = sym end - if i === nothing + if i == nothing if issymbollike(sym) && A.indepsym !== nothing && Symbol(sym) == A.indepsym A.t else @@ -88,7 +88,7 @@ Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym i = sym end - if i === nothing + if i == nothing if issymbollike(sym) && A.indepsym !== nothing && Symbol(sym) == A.indepsym A.t[args...] else From 713dc7e33505be891811081879c1debe3f86cd96 Mon Sep 17 00:00:00 2001 From: Sharan Yalburgi Date: Mon, 12 Jul 2021 22:46:21 +0530 Subject: [PATCH 4/4] Revert to `===` --- src/vector_of_array.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vector_of_array.jl b/src/vector_of_array.jl index 1609eba2..e32d4ddd 100644 --- a/src/vector_of_array.jl +++ b/src/vector_of_array.jl @@ -71,7 +71,7 @@ Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym i = sym end - if i == nothing + if i === nothing if issymbollike(sym) && A.indepsym !== nothing && Symbol(sym) == A.indepsym A.t else @@ -88,7 +88,7 @@ Base.@propagate_inbounds function Base.getindex(A::AbstractDiffEqArray{T, N},sym i = sym end - if i == nothing + if i === nothing if issymbollike(sym) && A.indepsym !== nothing && Symbol(sym) == A.indepsym A.t[args...] else