Skip to content

Commit

Permalink
Change the plot recipes to use the SymbolicIndexingInterface
Browse files Browse the repository at this point in the history
Fixes a whole lot of small issues.
  • Loading branch information
ChrisRackauckas committed Dec 27, 2023
1 parent 1ccfa8d commit d6bbac5
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 242 deletions.
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)

Check warning on line 755 in src/integrator_interface.jl

View check run for this annotation

Codecov / codecov/patch

src/integrator_interface.jl#L755

Added line #L755 was not covered by tests

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))

Check warning on line 759 in src/integrator_interface.jl

View check run for this annotation

Codecov / codecov/patch

src/integrator_interface.jl#L759

Added line #L759 was not covered by tests
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

Check warning on line 766 in src/integrator_interface.jl

View check run for this annotation

Codecov / codecov/patch

src/integrator_interface.jl#L766

Added line #L766 was not covered by tests
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

Check warning on line 783 in src/integrator_interface.jl

View check run for this annotation

Codecov / codecov/patch

src/integrator_interface.jl#L781-L783

Added lines #L781 - L783 were not covered by tests

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)

Check warning on line 789 in src/integrator_interface.jl

View check run for this annotation

Codecov / codecov/patch

src/integrator_interface.jl#L788-L789

Added lines #L788 - L789 were not covered by tests
else
push!(plot_vecs[j - 1], Vector(integrator(plott; idxs = x[j])))

Check warning on line 791 in src/integrator_interface.jl

View check run for this annotation

Codecov / codecov/patch

src/integrator_interface.jl#L791

Added line #L791 was not covered by tests
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])))

Check warning on line 806 in src/integrator_interface.jl

View check run for this annotation

Codecov / codecov/patch

src/integrator_interface.jl#L803-L806

Added lines #L803 - L806 were not covered by tests
else
push!(strs, "u[$(x[j])]")

Check warning on line 808 in src/integrator_interface.jl

View check run for this annotation

Codecov / codecov/patch

src/integrator_interface.jl#L808

Added line #L808 was not covered by tests
end
end
add_labels!(labels, x, dims, integrator.sol, strs)
end
Expand Down
Loading

0 comments on commit d6bbac5

Please sign in to comment.