From 5b77acd3552abb177adce90dec771a5864ab4467 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Wed, 24 Jul 2024 13:54:27 +0530 Subject: [PATCH] test: re-enable plotting tests --- test/downstream/integrator_indexing.jl | 31 ++++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/test/downstream/integrator_indexing.jl b/test/downstream/integrator_indexing.jl index b9dc62069..5db66cf7d 100644 --- a/test/downstream/integrator_indexing.jl +++ b/test/downstream/integrator_indexing.jl @@ -156,6 +156,7 @@ p = [lorenz1.σ => 10.0, tspan = (0.0, 100.0) prob = ODEProblem(sys, u0, tspan, p) integrator = init(prob, Rodas4()) +sol = solve(prob, Rodas4()) step!(integrator, 100.0, true) @test_throws Any integrator[b] @@ -318,14 +319,30 @@ integrator[lorenz2.x] = 2.0 # integrator10 = integrator(0.1, idxs = 2) # @test integrator10 isa Real -#= using Plots -plot(sol,idxs=(lorenz2.x,lorenz2.z)) -plot(sol,idxs=(α,lorenz2.z)) -plot(sol,idxs=(lorenz2.x,α)) -plot(sol,idxs=α) -plot(sol,idxs=(t,α)) -=# +for idxs in [ + (lorenz2.x,lorenz2.z), + (α,lorenz2.z), + (lorenz2.x,α), + α, + (α,), + (t,α), + [lorenz2.x,lorenz2.z], + [α,lorenz2.z], + [lorenz2.x,α], + [α], + [t,α], +] + plot(sol, idxs) + if idxs isa Union{Tuple, AbstractArray} + idxs = map(idx) do i + hasname(i) ? getname(i) : i + end + plot(sol, idxs) + elseif hasname(idxs) + plot(sol, idxs=getname(idxs)) + end +end using LinearAlgebra sts = @variables x(t)[1:3]=[1, 2, 3.0] y(t)=1.0