From 08949fc707a9947e4c6e6da4800a60b69db7a389 Mon Sep 17 00:00:00 2001 From: Pavan Chaggar <56822454+PavanChaggar@users.noreply.github.com> Date: Fri, 3 Sep 2021 10:06:24 +0100 Subject: [PATCH] changing sciml base indexing and adding test --- src/compat/scimlbase.jl | 11 ++++++----- test/diffeq_test/diffeq_tests.jl | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/compat/scimlbase.jl b/src/compat/scimlbase.jl index 167a3959..7fc47c0b 100644 --- a/src/compat/scimlbase.jl +++ b/src/compat/scimlbase.jl @@ -2,11 +2,12 @@ # Plotting stuff function SciMLBase.getsyms(sol::SciMLBase.AbstractODESolution{T,N,C}) where {T,N,C<:AbstractVector{<:ComponentArray}} - if SciMLBase.has_syms(sol.prob.f) - return sol.prob.f.syms - else - return labels(sol.u[1]) - end +# if SciMLBase.has_syms(sol.prob.f) +# return sol.prob.f.syms +# else +# return labels(sol.u[1]) +# end + keys(sol.prob.u0) end # A little bit of type piracy. Should probably make this a PR to DiffEqBase diff --git a/test/diffeq_test/diffeq_tests.jl b/test/diffeq_test/diffeq_tests.jl index 60b7b1c2..01f35c61 100644 --- a/test/diffeq_test/diffeq_tests.jl +++ b/test/diffeq_test/diffeq_tests.jl @@ -122,4 +122,23 @@ end @test (ctime - time)/time < 0.1 @test (ctime - ltime)/ltime < 0.05 end +end + +@testset "symbolic-indexing" begin + function lotka!(D, u, p, t; f=0) + @unpack α, β, γ, δ = p + @unpack x, y = u + + D.x = α*x - β*x*y + D.y = -γ*y + δ*x*y + return nothing + end + + lotka_p = (α=2/3, β=4/3, γ=1.0, δ=1.0) + lotka_ic = ComponentArray(x=1.0, y=1.0) + tspan = (0.0,10.0) + lotka_prob = ODEProblem(lotka!, lotka_ic, tspan, lotka_p) + sol = solve(lotka_prob, Tsit5(), saveat=1.0) + @test length(sol[:x]) == 11 + @test typeof(sol[:x]) == Vector{Float64} end \ No newline at end of file