From 3c5327de16051dd0ef800da15054584fad70e6f0 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Wed, 30 Oct 2024 16:21:05 +0530 Subject: [PATCH] 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`. --- src/scimlfunctions.jl | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/scimlfunctions.jl b/src/scimlfunctions.jl index 77a4f5077..b8e63928c 100644 --- a/src/scimlfunctions.jl +++ b/src/scimlfunctions.jl @@ -547,8 +547,8 @@ struct SplitFunction{ observed::O colorvec::TCV sys::SYS - initialization_data::ID nlprob::NLP + initialization_data::ID end @doc doc""" @@ -2518,7 +2518,8 @@ function ODEFunction{iip, specialize}(f; typeof(paramjac), typeof(observed), typeof(_colorvec), - typeof(sys), typeof(initdata), typeof(nlprob)}(_f, mass_matrix, analytic, tgrad, + typeof(sys), typeof(initdata), typeof(nlprob)}( + _f, mass_matrix, analytic, tgrad, jac, jvp, vjp, jac_prototype, sparsity, Wfact, Wfact_t, W_prototype, paramjac, observed, _colorvec, sys, initdata, nlprob) @@ -2686,7 +2687,7 @@ end @add_kwonly function SplitFunction(f1, f2, mass_matrix, 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) + initializeprobmap = nothing, initializeprobpmap = nothing, nlprob = nothing, initialization_data = nothing) f1 = ODEFunction(f1) f2 = ODEFunction(f2) @@ -4608,12 +4609,13 @@ end SymbolicIndexingInterface.constant_structure(::AbstractSciMLFunction) = true function Base.getproperty(x::Union{ODEFunction, SplitFunction, DAEFunction}, sym::Symbol) - if sym == :initializeprob || sym == :update_initializeprob! || sym == :initializeprobmap || sym == :initializeprobpmap - if x.initialization_data === nothing - return nothing - else - return getproperty(x.initialization_data, sym) + if sym == :initializeprob || sym == :update_initializeprob! || + sym == :initializeprobmap || sym == :initializeprobpmap + if x.initialization_data === nothing + return nothing + else + return getproperty(x.initialization_data, sym) + end end - end - return getfield(x, sym) + return getfield(x, sym) end