Skip to content

Commit 03aa8a2

Browse files
fix: reorder SplitFunction fields to avoid breaking change
The existing syntax is `initializeprob, ..., nlprob`. Trying to add `initialization_data` in the middle breaks the non-kwarg-only method. Putting it at the end fixes this issue. Anything old still has the order it relies on, with `initialization_data` defaulting to `nothing`, and anything new would just have to provide the redundant kwargs if it needs to specify `initialization_data`.
1 parent 6ee8151 commit 03aa8a2

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/scimlfunctions.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,8 @@ struct SplitFunction{
547547
observed::O
548548
colorvec::TCV
549549
sys::SYS
550-
initialization_data::ID
551550
nlprob::NLP
551+
initialization_data::ID
552552
end
553553

554554
@doc doc"""
@@ -2518,7 +2518,8 @@ function ODEFunction{iip, specialize}(f;
25182518
typeof(paramjac),
25192519
typeof(observed),
25202520
typeof(_colorvec),
2521-
typeof(sys), typeof(initdata), typeof(nlprob)}(_f, mass_matrix, analytic, tgrad,
2521+
typeof(sys), typeof(initdata), typeof(nlprob)}(
2522+
_f, mass_matrix, analytic, tgrad,
25222523
jac, jvp, vjp, jac_prototype, sparsity, Wfact,
25232524
Wfact_t, W_prototype, paramjac,
25242525
observed, _colorvec, sys, initdata, nlprob)
@@ -2686,7 +2687,7 @@ end
26862687
@add_kwonly function SplitFunction(f1, f2, mass_matrix, cache, analytic, tgrad, jac, jvp,
26872688
vjp, jac_prototype, W_prototype, sparsity, Wfact, Wfact_t, paramjac,
26882689
observed, colorvec, sys, initializeprob = nothing, update_initializeprob! = nothing,
2689-
initializeprobmap = nothing, initializeprobpmap = nothing, initialization_data = nothing, nlprob)
2690+
initializeprobmap = nothing, initializeprobpmap = nothing, nlprob = nothing, initialization_data = nothing)
26902691
f1 = ODEFunction(f1)
26912692
f2 = ODEFunction(f2)
26922693

@@ -4608,12 +4609,13 @@ end
46084609
SymbolicIndexingInterface.constant_structure(::AbstractSciMLFunction) = true
46094610

46104611
function Base.getproperty(x::Union{ODEFunction, SplitFunction, DAEFunction}, sym::Symbol)
4611-
if sym == :initializeprob || sym == :update_initializeprob! || sym == :initializeprobmap || sym == :initializeprobpmap
4612-
if x.initialization_data === nothing
4613-
return nothing
4614-
else
4615-
return getproperty(x.initialization_data, sym)
4612+
if sym == :initializeprob || sym == :update_initializeprob! ||
4613+
sym == :initializeprobmap || sym == :initializeprobpmap
4614+
if x.initialization_data === nothing
4615+
return nothing
4616+
else
4617+
return getproperty(x.initialization_data, sym)
4618+
end
46164619
end
4617-
end
4618-
return getfield(x, sym)
4620+
return getfield(x, sym)
46194621
end

0 commit comments

Comments
 (0)