From 5deef9d89a6641bfe2060eef8330748868808bd9 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Fri, 22 Aug 2025 13:46:10 +0530 Subject: [PATCH] fix: fix `strip_solution` for empty `ODEProblem` solutions --- src/solutions/ode_solutions.jl | 2 +- test/downstream/ode_stripping.jl | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/solutions/ode_solutions.jl b/src/solutions/ode_solutions.jl index e15a9e16ff..c30e0a6d25 100644 --- a/src/solutions/ode_solutions.jl +++ b/src/solutions/ode_solutions.jl @@ -671,7 +671,7 @@ function Base.showerror(io::IO, e::LazyInterpolationException) end function strip_solution(sol::ODESolution; strip_alg = false) - if has_lazy_interpolation(sol.alg) + if sol.alg !== nothing && has_lazy_interpolation(sol.alg) throw(LazyInterpolationException(nameof(typeof(sol.alg)))) end diff --git a/test/downstream/ode_stripping.jl b/test/downstream/ode_stripping.jl index a33d91d92e..b03db889e7 100644 --- a/test/downstream/ode_stripping.jl +++ b/test/downstream/ode_stripping.jl @@ -21,3 +21,12 @@ stripped_sol = SciMLBase.strip_solution(sol) @test isnothing(stripped_sol.interp.cache.jac_config) @test isnothing(stripped_sol.interp.cache.grad_config) + +@testset "`nothing` alg with empty ODE" begin + prob = ODEProblem(Returns(nothing), nothing, (0.0, 1.0), nothing) + sol = solve(prob, Tsit5()) + @test sol.alg === nothing + stripped_sol = SciMLBase.strip_solution(sol) + @test stripped_sol.alg === nothing + @test stripped_sol.prob == (; p = nothing) +end