Skip to content

Commit 2c3c46d

Browse files
Merge pull request #770 from jClugstor/solution_strip_test
Fix solution stripping for ODESolution
2 parents e17bf4e + eed4328 commit 2c3c46d

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

src/solutions/ode_solutions.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,7 @@ function strip_solution(sol::ODESolution)
613613

614614
interp = strip_interpolation(sol.interp)
615615

616-
ODESolution(sol.u, sol.u_analytic, sol.errors,
617-
sol.t, sol.k, sol.discretes, nothing, nothing,
618-
interp, sol.dense, sol.tslocation, sol.stats,
619-
sol.alg_choice, sol.retcode, sol.resid, sol.original)
616+
@reset sol.interp = interp
617+
@reset sol.prob = nothing
618+
return @set sol.alg = nothing
620619
end

test/downstream/ode_stripping.jl

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1-
using OrdinaryDiffEq
2-
f(u, p, t) = 1.01 * u
3-
u0 = 1 / 2
1+
using OrdinaryDiffEq, SciMLBase
2+
3+
function lorenz!(du, u, p, t)
4+
du[1] = 10.0 * (u[2] - u[1])
5+
du[2] = u[1] * (28.0 - u[3]) - u[2]
6+
du[3] = u[1] * u[2] - (8 / 3) * u[3]
7+
end
8+
9+
u0 = [1.0; 0.0; 0.0]
410
tspan = (0.0, 1.0)
5-
prob = ODEProblem(f, u0, tspan)
6-
sol = solve(prob, Tsit5(), reltol = 1e-8, abstol = 1e-8)
11+
prob = ODEProblem(lorenz!, u0, tspan)
12+
# implicit solver so we can test cache stripping worked
13+
sol = solve(prob, Rosenbrock23())
14+
15+
@test isnothing(SciMLBase.strip_solution(sol).prob)
16+
17+
@test isnothing(SciMLBase.strip_solution(sol).alg)
18+
19+
@test isnothing(SciMLBase.strip_solution(sol).interp.f)
720

8-
@test isnothing(strip_solution(sol).f)
21+
@test isnothing(SciMLBase.strip_solution(sol).interp.cache.jac_config)
922

10-
@test isnothing(strip_solution(sol).interp.f)
23+
@test isnothing(SciMLBase.strip_solution(sol).interp.cache.grad_config)

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ end
112112
@time @safetestset "Autodiff Observable Functions" begin
113113
include("downstream/observables_autodiff.jl")
114114
end
115+
@time @safetestset "ODE Solution Stripping" begin
116+
include("downstream/ode_stripping.jl")
117+
end
115118
end
116119

117120
if !is_APPVEYOR && (GROUP == "Downstream" || GROUP == "SymbolicIndexingInterface")

0 commit comments

Comments
 (0)