Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/problems/ode_problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,10 @@ function SplitODEProblem(f::SplitFunction, u0, tspan, p = NullParameters(); kwar
end
function SplitODEProblem{iip}(f::SplitFunction, u0, tspan, p = NullParameters();
kwargs...) where {iip}
if f.cache === nothing && iip
cache = similar(u0)
if f._func_cache === nothing && iip
_func_cache = similar(u0)
f = SplitFunction{iip}(f.f1, f.f2; mass_matrix = f.mass_matrix,
_func_cache = cache, analytic = f.analytic)
_func_cache = _func_cache, analytic = f.analytic)
end
ODEProblem(f, u0, tspan, p, SplitODEProblem{iip}(); kwargs...)
end
Expand Down
16 changes: 8 additions & 8 deletions src/problems/sde_problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ function SplitSDEProblem(f::SplitSDEFunction, u0, tspan, p = NullParameters(); k
end

function SplitSDEProblem{iip}(f::SplitSDEFunction, u0, tspan, p = NullParameters();
func_cache = nothing, kwargs...) where {iip}
if f.cache === nothing && iip
cache = similar(u0)
_func_cache = nothing, kwargs...) where {iip}
if f._func_cache === nothing && iip
_func_cache = similar(u0)
_f = SplitSDEFunction{iip}(f.f1, f.f2, f.g; mass_matrix = f.mass_matrix,
_func_cache = cache, analytic = f.analytic)
_func_cache = _func_cache, analytic = f.analytic)
else
_f = f
end
Expand Down Expand Up @@ -205,11 +205,11 @@ end

function DynamicalSDEProblem{iip}(f::DynamicalSDEFunction, v0, u0, tspan,
p = NullParameters();
func_cache = nothing, kwargs...) where {iip}
if f.cache === nothing && iip
cache = similar(u0)
_func_cache = nothing, kwargs...) where {iip}
if f._func_cache === nothing && iip
_func_cache = similar(u0)
_f = DynamicalSDEFunction{iip}(f.f1, f.f2, f.g; mass_matrix = f.mass_matrix,
_func_cache = cache, analytic = f.analytic)
_func_cache = _func_cache, analytic = f.analytic)
else
_f = f
end
Expand Down
6 changes: 3 additions & 3 deletions src/remake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ function remake(
args = (f,)
if is_split_function(T)
# for DynamicalSDEFunction and SplitFunction
if isdefined(props, :cache)
props = @insert props._func_cache = props.cache
props = @delete props.cache
if isdefined(props, :_func_cache)
props = @insert props._func_cache = props._func_cache
props = @delete props._func_cache
end

# `f1` and `f2` are wrapped in another SciMLFunction, unless they're
Expand Down
32 changes: 16 additions & 16 deletions src/scimlfunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@
f1::F1
f2::F2
mass_matrix::TMM
cache::C
_func_cache::C
analytic::Ta
tgrad::Tt
jac::TJ
Expand Down Expand Up @@ -1178,7 +1178,7 @@
f2::F2
g::G
mass_matrix::TMM
cache::C
_func_cache::C
analytic::Ta
tgrad::Tt
jac::TJ
Expand Down Expand Up @@ -1291,7 +1291,7 @@
f2::F2
g::G
mass_matrix::TMM
cache::C
_func_cache::C
analytic::Ta
tgrad::Tt
jac::TJ
Expand Down Expand Up @@ -1805,7 +1805,7 @@
In the above example, it will be the function:

```julia
functon polynomialize(u, p)

Check warning on line 1808 in src/scimlfunctions.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"functon" should be "function".
x, y = u
return [sin(x^2), log(x + y)]
end
Expand Down Expand Up @@ -2482,9 +2482,9 @@

(f::SplitFunction)(u, p, t) = f.f1(u, p, t) + f.f2(u, p, t)
function (f::SplitFunction)(du, u, p, t)
f.f1(f.cache, u, p, t)
f.f1(f._func_cache, u, p, t)
f.f2(du, u, p, t)
du .+= f.cache
du .+= f._func_cache
end

(f::DiscreteFunction)(args...) = f.f(args...)
Expand Down Expand Up @@ -2512,9 +2512,9 @@
(f::SplitSDEFunction)(u, p, t) = f.f1(u, p, t) + f.f2(u, p, t)

function (f::SplitSDEFunction)(du, u, p, t)
f.f1(f.cache, u, p, t)
f.f1(f._func_cache, u, p, t)
f.f2(du, u, p, t)
du .+= f.cache
du .+= f._func_cache
end

(f::RODEFunction)(args...) = f.f(args...)
Expand Down Expand Up @@ -2808,7 +2808,7 @@
end
end

@add_kwonly function SplitFunction(f1, f2, mass_matrix, cache, analytic, tgrad, jac, jvp,
@add_kwonly function SplitFunction(f1, f2, mass_matrix, _func_cache, analytic, tgrad, jac, jvp,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
@add_kwonly function SplitFunction(f1, f2, mass_matrix, _func_cache, analytic, tgrad, jac, jvp,
@add_kwonly function SplitFunction(
f1, f2, mass_matrix, _func_cache, analytic, tgrad, jac, jvp,

vjp, jac_prototype, W_prototype, sparsity, Wfact, Wfact_t, paramjac,
observed, colorvec, sys, initializeprob = nothing, update_initializeprob! = nothing,
initializeprobmap = nothing, initializeprobpmap = nothing, initialization_data = nothing, nlprob_data = nothing)
Expand All @@ -2826,12 +2826,12 @@

SplitFunction{isinplace(f2), FullSpecialize, typeof(f1), typeof(f2),
typeof(mass_matrix),
typeof(cache), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp),
typeof(_func_cache), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp),
typeof(vjp), typeof(jac_prototype), typeof(W_prototype), typeof(sparsity),
typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(colorvec),
typeof(sys), typeof(initdata), typeof(nlprob_data)}(
f1, f2, mass_matrix,
cache, analytic, tgrad, jac, jvp, vjp,
_func_cache, analytic, tgrad, jac, jvp, vjp,
jac_prototype, W_prototype, sparsity, Wfact, Wfact_t, paramjac, observed, colorvec, sys,
initdata, nlprob_data)
end
Expand Down Expand Up @@ -3259,20 +3259,20 @@
end
SDEFunction(f::SDEFunction; kwargs...) = f

@add_kwonly function SplitSDEFunction(f1, f2, g, mass_matrix, cache, analytic, tgrad, jac,
@add_kwonly function SplitSDEFunction(f1, f2, g, mass_matrix, _func_cache, analytic, tgrad, jac,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
@add_kwonly function SplitSDEFunction(f1, f2, g, mass_matrix, _func_cache, analytic, tgrad, jac,
@add_kwonly function SplitSDEFunction(
f1, f2, g, mass_matrix, _func_cache, analytic, tgrad, jac,

jvp, vjp,
jac_prototype, Wfact, Wfact_t, paramjac, observed,
colorvec, sys, initialization_data = nothing)
f1 = f1 isa AbstractSciMLOperator ? f1 : SDEFunction(f1)
f2 = SDEFunction(f2)

SplitFunction{isinplace(f2), typeof(f1), typeof(f2), typeof(g), typeof(mass_matrix),
typeof(cache), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp),
typeof(_func_cache), typeof(analytic), typeof(tgrad), typeof(jac), typeof(jvp),
typeof(vjp),
typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed),
typeof(colorvec),
typeof(sys), typeof(initialization_data)}(
f1, f2, mass_matrix, cache, analytic, tgrad, jac,
f1, f2, mass_matrix, _func_cache, analytic, tgrad, jac,
jac_prototype, Wfact, Wfact_t, paramjac, observed, colorvec, sys, initialization_data)
end

Expand Down Expand Up @@ -3344,7 +3344,7 @@
end
SplitSDEFunction(f::SplitSDEFunction; kwargs...) = f

@add_kwonly function DynamicalSDEFunction(f1, f2, g, mass_matrix, cache, analytic, tgrad,
@add_kwonly function DynamicalSDEFunction(f1, f2, g, mass_matrix, _func_cache, analytic, tgrad,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
@add_kwonly function DynamicalSDEFunction(f1, f2, g, mass_matrix, _func_cache, analytic, tgrad,
@add_kwonly function DynamicalSDEFunction(
f1, f2, g, mass_matrix, _func_cache, analytic, tgrad,

jac, jvp, vjp,
jac_prototype, Wfact, Wfact_t, paramjac,
observed, colorvec,
Expand All @@ -3354,12 +3354,12 @@

DynamicalSDEFunction{isinplace(f2), FullSpecialize, typeof(f1), typeof(f2), typeof(g),
typeof(mass_matrix),
typeof(cache), typeof(analytic), typeof(tgrad), typeof(jac),
typeof(_func_cache), typeof(analytic), typeof(tgrad), typeof(jac),
typeof(jvp), typeof(vjp),
typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed),
typeof(colorvec),
typeof(sys), typeof(initialization_data)}(
f1, f2, g, mass_matrix, cache, analytic, tgrad,
f1, f2, g, mass_matrix, _func_cache, analytic, tgrad,
jac, jac_prototype, Wfact, Wfact_t, paramjac, observed, colorvec, sys,
initialization_data)
end
Expand Down
Loading