From 99552001aa232781c59c3ec6a44a4a90cfb29f96 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Thu, 10 Oct 2024 12:05:14 -0400 Subject: [PATCH 1/5] fix cache strip --- lib/OrdinaryDiffEqCore/src/interp_func.jl | 27 ++++++++--------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/lib/OrdinaryDiffEqCore/src/interp_func.jl b/lib/OrdinaryDiffEqCore/src/interp_func.jl index 36debb6883..4cf9d11fc7 100644 --- a/lib/OrdinaryDiffEqCore/src/interp_func.jl +++ b/lib/OrdinaryDiffEqCore/src/interp_func.jl @@ -75,24 +75,15 @@ function SciMLBase.strip_interpolation(id::InterpolationData) end function strip_cache(cache) - if hasfield(typeof(cache), :jac_config) - SciMLBase.@reset cache.jac_config = nothing + if !(cache isa OrdinaryDiffEqCore.DefaultCache) + cache = SciMLBase.constructorof(typeof(cache))([nothing + for name in fieldnames(typeof(cache))]...) + else + # need to do something special for default cache + noth_type = Nothing + cache = OrdinaryDiffEqCore.DefaultCache{noth_type, noth_type, noth_type, noth_type, + noth_type, noth_type, noth_type, noth_type}(nothing, nothing, 0, nothing) end - if hasfield(typeof(cache), :grad_config) - SciMLBase.@reset cache.grad_config = nothing - end - if hasfield(typeof(cache), :nlsolver) - SciMLBase.@reset cache.nlsolver = nothing - end - if hasfield(typeof(cache), :tf) - SciMLBase.@reset cache.tf = nothing - end - if hasfield(typeof(cache), :uf) - SciMLBase.@reset cache.uf = nothing - end - if hasfield(typeof(cache),:args) - SciMLBase.@reset cache.args = nothing - end - + cache end From 57de663c6a2058e01e82cda8742b036f349b4007 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Thu, 10 Oct 2024 12:07:28 -0400 Subject: [PATCH 2/5] more tests --- test/interface/ode_strip_test.jl | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/test/interface/ode_strip_test.jl b/test/interface/ode_strip_test.jl index ad5a794bd8..f30a4492aa 100644 --- a/test/interface/ode_strip_test.jl +++ b/test/interface/ode_strip_test.jl @@ -14,7 +14,7 @@ prob = ODEProblem(lorenz!, u0, tspan) rosenbrock_sol = solve(prob, Rosenbrock23()) TRBDF_sol = solve(prob, TRBDF2()) vern_sol = solve(prob, Vern7()) - +default_sol = solve(prob) @testset "Interpolation Stripping" begin @test isnothing(SciMLBase.strip_interpolation(rosenbrock_sol.interp).f) @test isnothing(SciMLBase.strip_interpolation(rosenbrock_sol.interp).cache.jac_config) @@ -22,20 +22,28 @@ vern_sol = solve(prob, Vern7()) end @testset "Rosenbrock Solution Stripping" begin - @test SciMLBase.strip_solution(rosenbrock_sol).prob isa NamedTuple + stripped_sol = SciMLBase.strip_solution(rosenbrock_sol) + @test stripped_sol.prob isa NamedTuple @test isnothing(SciMLBase.strip_solution(rosenbrock_sol, strip_alg = true).alg) - @test isnothing(SciMLBase.strip_solution(rosenbrock_sol).interp.f) - @test isnothing(SciMLBase.strip_solution(rosenbrock_sol).interp.cache.jac_config) - @test isnothing(SciMLBase.strip_solution(rosenbrock_sol).interp.cache.grad_config) - @test isnothing(SciMLBase.strip_solution(rosenbrock_sol).interp.cache.uf) - @test isnothing(SciMLBase.strip_solution(rosenbrock_sol).interp.cache.tf) + @test isnothing(stripped_sol.interp.f) + @test isnothing(stripped_sol.interp.cache.jac_config) + @test isnothing(stripped_sol.interp.cache.grad_config) + @test isnothing(stripped_sol.interp.cache.uf) + @test isnothing(stripped_sol.interp.cache.tf) end @testset "TRBDF Solution Stripping" begin - @test SciMLBase.strip_solution(TRBDF_sol).prob isa NamedTuple + stripped_sol = SciMLBase.strip_solution(TRBDF_sol) + @test stripped_sol.prob isa NamedTuple @test isnothing(SciMLBase.strip_solution(TRBDF_sol, strip_alg = true).alg) - @test isnothing(SciMLBase.strip_solution(TRBDF_sol).interp.f) - @test isnothing(SciMLBase.strip_solution(TRBDF_sol).interp.cache.nlsolver) + @test isnothing(stripped_sol.interp.f) + @test isnothing(stripped_sol.interp.cache.nlsolver) +end + +@testset "Default Solution Stripping" begin + stripped_sol = SciMLBase.strip_solution(default_sol) + @test isnothing(stripped_sol.interp.cache.args) + end @test_throws SciMLBase.LazyInterpolationException SciMLBase.strip_solution(vern_sol) From 96a914f60a7e44d2d5e9321fb48e3c95e1bbf5bb Mon Sep 17 00:00:00 2001 From: jClugstor Date: Thu, 10 Oct 2024 12:07:47 -0400 Subject: [PATCH 3/5] change again --- lib/OrdinaryDiffEqCore/src/interp_func.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/OrdinaryDiffEqCore/src/interp_func.jl b/lib/OrdinaryDiffEqCore/src/interp_func.jl index 4cf9d11fc7..dfa3dee146 100644 --- a/lib/OrdinaryDiffEqCore/src/interp_func.jl +++ b/lib/OrdinaryDiffEqCore/src/interp_func.jl @@ -80,9 +80,8 @@ function strip_cache(cache) for name in fieldnames(typeof(cache))]...) else # need to do something special for default cache - noth_type = Nothing - cache = OrdinaryDiffEqCore.DefaultCache{noth_type, noth_type, noth_type, noth_type, - noth_type, noth_type, noth_type, noth_type}(nothing, nothing, 0, nothing) + cache = OrdinaryDiffEqCore.DefaultCache{Nothing, Nothing, Nothing, Nothing, + Nothing, Nothing, Nothing, Nothing}(nothing, nothing, 0, nothing) end cache From f76db3c0aedc81dc4f0fc59742fb6ea56d16e17f Mon Sep 17 00:00:00 2001 From: jClugstor Date: Thu, 10 Oct 2024 12:37:21 -0400 Subject: [PATCH 4/5] add patch number --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 2ac3331b5e..a0dec2d8b8 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "OrdinaryDiffEq" uuid = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" authors = ["Chris Rackauckas ", "Yingbo Ma "] -version = "6.89.0" +version = "6.89.1" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" From 52256a19e4c05ee39ea113a2d8849b33b2676e81 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Thu, 10 Oct 2024 12:59:01 -0400 Subject: [PATCH 5/5] change versions --- Project.toml | 2 +- lib/OrdinaryDiffEqCore/Project.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index a0dec2d8b8..2ac3331b5e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "OrdinaryDiffEq" uuid = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" authors = ["Chris Rackauckas ", "Yingbo Ma "] -version = "6.89.1" +version = "6.89.0" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" diff --git a/lib/OrdinaryDiffEqCore/Project.toml b/lib/OrdinaryDiffEqCore/Project.toml index 68579225a2..5f29c546a8 100644 --- a/lib/OrdinaryDiffEqCore/Project.toml +++ b/lib/OrdinaryDiffEqCore/Project.toml @@ -1,7 +1,7 @@ name = "OrdinaryDiffEqCore" uuid = "bbf590c4-e513-4bbe-9b18-05decba2e5d8" authors = ["ParamThakkar123 "] -version = "1.7.0" +version = "1.7.1" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"