Skip to content

Add safety around the solver stats #31

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
19 changes: 13 additions & 6 deletions src/MATLABDiffEq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,20 @@ function DiffEqBase.__solve(
# Send the function over
eval_string(matstr)

eval_string("options = odeset('RelTol',reltol,'AbsTol',abstol);")
eval_string("options = odeset('RelTol',reltol,'AbsTol',abstol,'Stats',);")
algstr = string(typeof(alg).name.name)
eval_string("mxsol = $(algstr)(diffeqf,tspan,u0,options);")
eval_string("mxsolstats = struct(mxsol.stats);")
solstats = get_variable(:mxsolstats)

eval_string("statsexists = isfield(mxsol,'stats')")
hasstats = get_variable(:statsexists)
if hasstats
eval_string("mxsolstats = struct(mxsol.stats);")
solstats = get_variable(:mxsolstats)
destats = buildDEStats(solstats)
else
destats = nothing
end

eval_string("t = mxsol.x;")
ts = jvector(get_mvariable(:t))
eval_string("u = mxsol.y';")
Expand All @@ -81,9 +90,7 @@ function DiffEqBase.__solve(
end
else
timeseries = timeseries_tmp
end

destats = buildDEStats(solstats)
end

DiffEqBase.build_solution(prob,alg,ts,timeseries,
timeseries_errors = timeseries_errors,destats = destats)
Expand Down