Skip to content
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

Change the plot recipes to use the SymbolicIndexingInterface #572

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 @@
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 @@
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 @@
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
Loading