Skip to content

Change the plot recipes to use the SymbolicIndexingInterface #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions src/integrator_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -752,20 +752,19 @@ Base.length(iter::TimeChoiceIterator) = length(iter.ts)
idxs = vars
end

syms = getsyms(integrator)
int_vars = interpret_vars(idxs, integrator.sol, syms)
strs = cleansyms(syms)
int_vars = interpret_vars(idxs, integrator.sol)

if denseplot
# Generate the points from the plot from dense function
plott = collect(range(integrator.tprev; step = integrator.t, length = plotdensity))
plot_timeseries = integrator(plott)
plott = collect(range(integrator.tprev, integrator.t; length = plotdensity))
if plot_analytic
plot_analytic_timeseries = [integrator.sol.prob.f.analytic(integrator.sol.prob.u0,
integrator.sol.prob.p,
t) for t in plott]
end
end # if not denseplot, we'll just get the values right from the integrator.
else
plott = nothing
end

dims = length(int_vars[1])
for var in int_vars
Expand All @@ -779,11 +778,18 @@ Base.length(iter::TimeChoiceIterator) = length(iter.ts)
end

labels = String[]# Array{String, 2}(1, length(int_vars)*(1+plot_analytic))
strs = String[]
varsyms = variable_symbols(integrator)
@show plott

for x in int_vars
for j in 2:dims
if denseplot
push!(plot_vecs[j - 1],
u_n(plot_timeseries, x[j], integrator.sol, plott, plot_timeseries))
if (x[j] isa Integer && x[j] == 0) || isequal(x[j],getindepsym_defaultt(integrator))
push!(plot_vecs[j - 1], plott)
else
push!(plot_vecs[j - 1], Vector(integrator(plott; idxs = x[j])))
end
else # just get values
if x[j] == 0
push!(plot_vecs[j - 1], integrator.t)
Expand All @@ -793,6 +799,14 @@ Base.length(iter::TimeChoiceIterator) = length(iter.ts)
push!(plot_vecs[j - 1], integrator.u[x[j]])
end
end

if !isempty(varsyms) && x[j] isa Integer
push!(strs, String(getname(varsyms[x[j]])))
elseif hasname(x[j])
push!(strs, String(getname(x[j])))
else
push!(strs, "u[$(x[j])]")
end
end
add_labels!(labels, x, dims, integrator.sol, strs)
end
Expand Down
Loading