Skip to content

Commit d6dbc0e

Browse files
Merge pull request #932 from SciML/cachename
Fix cache name in SplitFunction
2 parents a0e8e7b + 23eab1c commit d6dbc0e

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

src/problems/ode_problems.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,10 @@ function SplitODEProblem(f::SplitFunction, u0, tspan, p = NullParameters(); kwar
473473
end
474474
function SplitODEProblem{iip}(f::SplitFunction, u0, tspan, p = NullParameters();
475475
kwargs...) where {iip}
476-
if f.cache === nothing && iip
477-
cache = similar(u0)
476+
if f._func_cache === nothing && iip
477+
_func_cache = similar(u0)
478478
f = SplitFunction{iip}(f.f1, f.f2; mass_matrix = f.mass_matrix,
479-
_func_cache = cache, analytic = f.analytic)
479+
_func_cache = _func_cache, analytic = f.analytic)
480480
end
481481
ODEProblem(f, u0, tspan, p, SplitODEProblem{iip}(); kwargs...)
482482
end

src/problems/sde_problems.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ function SplitSDEProblem(f::SplitSDEFunction, u0, tspan, p = NullParameters(); k
166166
end
167167

168168
function SplitSDEProblem{iip}(f::SplitSDEFunction, u0, tspan, p = NullParameters();
169-
func_cache = nothing, kwargs...) where {iip}
170-
if f.cache === nothing && iip
171-
cache = similar(u0)
169+
_func_cache = nothing, kwargs...) where {iip}
170+
if f._func_cache === nothing && iip
171+
_func_cache = similar(u0)
172172
_f = SplitSDEFunction{iip}(f.f1, f.f2, f.g; mass_matrix = f.mass_matrix,
173-
_func_cache = cache, analytic = f.analytic)
173+
_func_cache = _func_cache, analytic = f.analytic)
174174
else
175175
_f = f
176176
end
@@ -205,11 +205,11 @@ end
205205

206206
function DynamicalSDEProblem{iip}(f::DynamicalSDEFunction, v0, u0, tspan,
207207
p = NullParameters();
208-
func_cache = nothing, kwargs...) where {iip}
209-
if f.cache === nothing && iip
210-
cache = similar(u0)
208+
_func_cache = nothing, kwargs...) where {iip}
209+
if f._func_cache === nothing && iip
210+
_func_cache = similar(u0)
211211
_f = DynamicalSDEFunction{iip}(f.f1, f.f2, f.g; mass_matrix = f.mass_matrix,
212-
_func_cache = cache, analytic = f.analytic)
212+
_func_cache = _func_cache, analytic = f.analytic)
213213
else
214214
_f = f
215215
end

src/remake.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ function remake(
167167
args = (f,)
168168
if is_split_function(T)
169169
# for DynamicalSDEFunction and SplitFunction
170-
if isdefined(props, :cache)
171-
props = @insert props._func_cache = props.cache
172-
props = @delete props.cache
170+
if isdefined(props, :_func_cache)
171+
props = @insert props._func_cache = props._func_cache
172+
props = @delete props._func_cache
173173
end
174174

175175
# `f1` and `f2` are wrapped in another SciMLFunction, unless they're

src/scimlfunctions.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ struct SplitFunction{
536536
f1::F1
537537
f2::F2
538538
mass_matrix::TMM
539-
cache::C
539+
_func_cache::C
540540
analytic::Ta
541541
tgrad::Tt
542542
jac::TJ
@@ -1178,7 +1178,7 @@ struct SplitSDEFunction{iip, specialize, F1, F2, G, TMM, C, Ta, Tt, TJ, JVP, VJP
11781178
f2::F2
11791179
g::G
11801180
mass_matrix::TMM
1181-
cache::C
1181+
_func_cache::C
11821182
analytic::Ta
11831183
tgrad::Tt
11841184
jac::TJ
@@ -1291,7 +1291,7 @@ struct DynamicalSDEFunction{iip, specialize, F1, F2, G, TMM, C, Ta, Tt, TJ, JVP,
12911291
f2::F2
12921292
g::G
12931293
mass_matrix::TMM
1294-
cache::C
1294+
_func_cache::C
12951295
analytic::Ta
12961296
tgrad::Tt
12971297
jac::TJ
@@ -2482,9 +2482,9 @@ end
24822482

24832483
(f::SplitFunction)(u, p, t) = f.f1(u, p, t) + f.f2(u, p, t)
24842484
function (f::SplitFunction)(du, u, p, t)
2485-
f.f1(f.cache, u, p, t)
2485+
f.f1(f._func_cache, u, p, t)
24862486
f.f2(du, u, p, t)
2487-
du .+= f.cache
2487+
du .+= f._func_cache
24882488
end
24892489

24902490
(f::DiscreteFunction)(args...) = f.f(args...)
@@ -2512,9 +2512,9 @@ end
25122512
(f::SplitSDEFunction)(u, p, t) = f.f1(u, p, t) + f.f2(u, p, t)
25132513

25142514
function (f::SplitSDEFunction)(du, u, p, t)
2515-
f.f1(f.cache, u, p, t)
2515+
f.f1(f._func_cache, u, p, t)
25162516
f.f2(du, u, p, t)
2517-
du .+= f.cache
2517+
du .+= f._func_cache
25182518
end
25192519

25202520
(f::RODEFunction)(args...) = f.f(args...)
@@ -2808,7 +2808,7 @@ function unwrapped_f(f::NonlinearFunction, newf = unwrapped_f(f.f))
28082808
end
28092809
end
28102810

2811-
@add_kwonly function SplitFunction(f1, f2, mass_matrix, cache, analytic, tgrad, jac, jvp,
2811+
@add_kwonly function SplitFunction(f1, f2, mass_matrix, _func_cache, analytic, tgrad, jac, jvp,
28122812
vjp, jac_prototype, W_prototype, sparsity, Wfact, Wfact_t, paramjac,
28132813
observed, colorvec, sys, initializeprob = nothing, update_initializeprob! = nothing,
28142814
initializeprobmap = nothing, initializeprobpmap = nothing, initialization_data = nothing, nlprob_data = nothing)
@@ -2826,12 +2826,12 @@ end
28262826

28272827
SplitFunction{isinplace(f2), FullSpecialize, typeof(f1), typeof(f2),
28282828
typeof(mass_matrix),
2829-
typeof(cache), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp),
2829+
typeof(_func_cache), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp),
28302830
typeof(vjp), typeof(jac_prototype), typeof(W_prototype), typeof(sparsity),
28312831
typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(colorvec),
28322832
typeof(sys), typeof(initdata), typeof(nlprob_data)}(
28332833
f1, f2, mass_matrix,
2834-
cache, analytic, tgrad, jac, jvp, vjp,
2834+
_func_cache, analytic, tgrad, jac, jvp, vjp,
28352835
jac_prototype, W_prototype, sparsity, Wfact, Wfact_t, paramjac, observed, colorvec, sys,
28362836
initdata, nlprob_data)
28372837
end
@@ -3259,20 +3259,20 @@ function SDEFunction(f, g; kwargs...)
32593259
end
32603260
SDEFunction(f::SDEFunction; kwargs...) = f
32613261

3262-
@add_kwonly function SplitSDEFunction(f1, f2, g, mass_matrix, cache, analytic, tgrad, jac,
3262+
@add_kwonly function SplitSDEFunction(f1, f2, g, mass_matrix, _func_cache, analytic, tgrad, jac,
32633263
jvp, vjp,
32643264
jac_prototype, Wfact, Wfact_t, paramjac, observed,
32653265
colorvec, sys, initialization_data = nothing)
32663266
f1 = f1 isa AbstractSciMLOperator ? f1 : SDEFunction(f1)
32673267
f2 = SDEFunction(f2)
32683268

32693269
SplitFunction{isinplace(f2), typeof(f1), typeof(f2), typeof(g), typeof(mass_matrix),
3270-
typeof(cache), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp),
3270+
typeof(_func_cache), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp),
32713271
typeof(vjp),
32723272
typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed),
32733273
typeof(colorvec),
32743274
typeof(sys), typeof(initialization_data)}(
3275-
f1, f2, mass_matrix, cache, analytic, tgrad, jac,
3275+
f1, f2, mass_matrix, _func_cache, analytic, tgrad, jac,
32763276
jac_prototype, Wfact, Wfact_t, paramjac, observed, colorvec, sys, initialization_data)
32773277
end
32783278

@@ -3344,7 +3344,7 @@ function SplitSDEFunction{iip}(f1, f2, g; kwargs...) where {iip}
33443344
end
33453345
SplitSDEFunction(f::SplitSDEFunction; kwargs...) = f
33463346

3347-
@add_kwonly function DynamicalSDEFunction(f1, f2, g, mass_matrix, cache, analytic, tgrad,
3347+
@add_kwonly function DynamicalSDEFunction(f1, f2, g, mass_matrix, _func_cache, analytic, tgrad,
33483348
jac, jvp, vjp,
33493349
jac_prototype, Wfact, Wfact_t, paramjac,
33503350
observed, colorvec,
@@ -3354,12 +3354,12 @@ SplitSDEFunction(f::SplitSDEFunction; kwargs...) = f
33543354

33553355
DynamicalSDEFunction{isinplace(f2), FullSpecialize, typeof(f1), typeof(f2), typeof(g),
33563356
typeof(mass_matrix),
3357-
typeof(cache), typeof(analytic), typeof(tgrad), typeof(jac),
3357+
typeof(_func_cache), typeof(analytic), typeof(tgrad), typeof(jac),
33583358
typeof(jvp), typeof(vjp),
33593359
typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed),
33603360
typeof(colorvec),
33613361
typeof(sys), typeof(initialization_data)}(
3362-
f1, f2, g, mass_matrix, cache, analytic, tgrad,
3362+
f1, f2, g, mass_matrix, _func_cache, analytic, tgrad,
33633363
jac, jac_prototype, Wfact, Wfact_t, paramjac, observed, colorvec, sys,
33643364
initialization_data)
33653365
end

0 commit comments

Comments
 (0)