Skip to content

Commit 6eabcae

Browse files
Merge pull request #2473 from jClugstor/strip_sol_fix
Cache stripping fix
2 parents 733bfa5 + ddbdc6c commit 6eabcae

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ PrecompileTools = "1"
133133
Preferences = "1.3"
134134
RecursiveArrayTools = "2.36, 3"
135135
Reexport = "1.0"
136-
SciMLBase = "2.53"
136+
SciMLBase = "2.53.2"
137137
SciMLOperators = "0.3"
138138
SciMLStructures = "1"
139139
SimpleNonlinearSolve = "1"

lib/OrdinaryDiffEqCore/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "OrdinaryDiffEqCore"
22
uuid = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
33
authors = ["ParamThakkar123 <[email protected]>"]
4-
version = "1.6.0"
4+
version = "1.6.1"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

lib/OrdinaryDiffEqCore/src/interp_func.jl

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,21 @@ function SciMLBase.strip_interpolation(id::InterpolationData)
7575
end
7676

7777
function strip_cache(cache)
78-
if hasfield(typeof(cache), :jac_config) || hasfield(typeof(cache), :grad_config) ||
79-
hasfield(typeof(cache), :nlsolver) || hasfield(typeof(cache), :tf) ||
80-
hasfield(typeof(cache), :uf)
81-
fieldnums = length(fieldnames(typeof(cache)))
82-
noth_list = fill(nothing, fieldnums)
83-
cache_type_name = Base.typename(typeof(cache)).wrapper
84-
cache_type_name(noth_list...)
85-
else
86-
cache
78+
if hasfield(typeof(cache), :jac_config)
79+
SciMLBase.@reset cache.jac_config = nothing
8780
end
81+
if hasfield(typeof(cache), :grad_config)
82+
SciMLBase.@reset cache.grad_config = nothing
83+
end
84+
if hasfield(typeof(cache), :nlsolver)
85+
SciMLBase.@reset cache.nlsolver = nothing
86+
end
87+
if hasfield(typeof(cache), :tf)
88+
SciMLBase.@reset cache.tf = nothing
89+
end
90+
if hasfield(typeof(cache), :uf)
91+
SciMLBase.@reset cache.uf = nothing
92+
end
93+
94+
cache
8895
end

test/interface/ode_strip_test.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ prob = ODEProblem(lorenz!, u0, tspan)
1414
rosenbrock_sol = solve(prob, Rosenbrock23())
1515
TRBDF_sol = solve(prob, TRBDF2())
1616
vern_sol = solve(prob, Vern7())
17+
1718
@testset "Interpolation Stripping" begin
1819
@test isnothing(SciMLBase.strip_interpolation(rosenbrock_sol.interp).f)
1920
@test isnothing(SciMLBase.strip_interpolation(rosenbrock_sol.interp).cache.jac_config)
2021
@test isnothing(SciMLBase.strip_interpolation(rosenbrock_sol.interp).cache.grad_config)
2122
end
2223

2324
@testset "Rosenbrock Solution Stripping" begin
24-
@test isnothing(SciMLBase.strip_solution(rosenbrock_sol).prob)
25-
@test isnothing(SciMLBase.strip_solution(rosenbrock_sol).alg)
25+
@test SciMLBase.strip_solution(rosenbrock_sol).prob isa NamedTuple
26+
@test isnothing(SciMLBase.strip_solution(rosenbrock_sol, strip_alg = true).alg)
2627
@test isnothing(SciMLBase.strip_solution(rosenbrock_sol).interp.f)
2728
@test isnothing(SciMLBase.strip_solution(rosenbrock_sol).interp.cache.jac_config)
2829
@test isnothing(SciMLBase.strip_solution(rosenbrock_sol).interp.cache.grad_config)
@@ -31,8 +32,8 @@ end
3132
end
3233

3334
@testset "TRBDF Solution Stripping" begin
34-
@test isnothing(SciMLBase.strip_solution(TRBDF_sol).prob)
35-
@test isnothing(SciMLBase.strip_solution(TRBDF_sol).alg)
35+
@test SciMLBase.strip_solution(TRBDF_sol).prob isa NamedTuple
36+
@test isnothing(SciMLBase.strip_solution(TRBDF_sol, strip_alg = true).alg)
3637
@test isnothing(SciMLBase.strip_solution(TRBDF_sol).interp.f)
3738
@test isnothing(SciMLBase.strip_solution(TRBDF_sol).interp.cache.nlsolver)
3839
end

0 commit comments

Comments
 (0)