Skip to content

Commit 1e6720c

Browse files
Merge pull request #790 from jClugstor/strip_sol_fix
Fix interpolation for stripped solutions
2 parents 4a0c5e8 + d777184 commit 1e6720c

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/solutions/ode_solutions.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,14 +619,20 @@ function Base.showerror(io::IO, e::LazyInterpolationException)
619619
" uses lazy interpolation, which is incompatible with `strip_solution`.")
620620
end
621621

622-
function strip_solution(sol::ODESolution)
622+
function strip_solution(sol::ODESolution; strip_alg = false)
623623
if has_lazy_interpolation(sol.alg)
624624
throw(LazyInterpolationException(nameof(typeof(sol.alg))))
625625
end
626626

627627
interp = strip_interpolation(sol.interp)
628628

629629
@reset sol.interp = interp
630-
@reset sol.prob = nothing
631-
return @set sol.alg = nothing
630+
631+
@reset sol.prob = (; p = nothing)
632+
633+
if strip_alg
634+
@reset sol.alg = nothing
635+
end
636+
637+
return sol
632638
end

test/downstream/ode_stripping.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ prob = ODEProblem(lorenz!, u0, tspan)
1212
# implicit solver so we can test cache stripping worked
1313
sol = solve(prob, Rosenbrock23())
1414

15-
@test isnothing(SciMLBase.strip_solution(sol).prob)
15+
stripped_sol = SciMLBase.strip_solution(sol)
1616

17-
@test isnothing(SciMLBase.strip_solution(sol).alg)
17+
@test isnothing(SciMLBase.strip_solution(sol, strip_alg = true).alg)
1818

19-
@test isnothing(SciMLBase.strip_solution(sol).interp.f)
19+
@test isnothing(stripped_sol.interp.f)
2020

21-
@test isnothing(SciMLBase.strip_solution(sol).interp.cache.jac_config)
21+
@test isnothing(stripped_sol.interp.cache.jac_config)
2222

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

0 commit comments

Comments
 (0)