Skip to content

Commit 5deef9d

Browse files
fix: fix strip_solution for empty ODEProblem solutions
1 parent a6feb53 commit 5deef9d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/solutions/ode_solutions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ function Base.showerror(io::IO, e::LazyInterpolationException)
671671
end
672672

673673
function strip_solution(sol::ODESolution; strip_alg = false)
674-
if has_lazy_interpolation(sol.alg)
674+
if sol.alg !== nothing && has_lazy_interpolation(sol.alg)
675675
throw(LazyInterpolationException(nameof(typeof(sol.alg))))
676676
end
677677

test/downstream/ode_stripping.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,12 @@ stripped_sol = SciMLBase.strip_solution(sol)
2121
@test isnothing(stripped_sol.interp.cache.jac_config)
2222

2323
@test isnothing(stripped_sol.interp.cache.grad_config)
24+
25+
@testset "`nothing` alg with empty ODE" begin
26+
prob = ODEProblem(Returns(nothing), nothing, (0.0, 1.0), nothing)
27+
sol = solve(prob, Tsit5())
28+
@test sol.alg === nothing
29+
stripped_sol = SciMLBase.strip_solution(sol)
30+
@test stripped_sol.alg === nothing
31+
@test stripped_sol.prob == (; p = nothing)
32+
end

0 commit comments

Comments
 (0)