Skip to content

Commit 955669a

Browse files
committed
fixes strip_cache
1 parent b0f957c commit 955669a

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

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

0 commit comments

Comments
 (0)