From 4ea5fd04e17dcc55e8f88799f27e2ee623d86eeb Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Wed, 30 Oct 2024 17:06:06 +0530 Subject: [PATCH] fix: move `initializeprob` typeasserts to `OverrideInitData` --- src/initialization.jl | 6 ++++++ src/scimlfunctions.jl | 10 +--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/initialization.jl b/src/initialization.jl index 6cbbcda72..c058e0cd3 100644 --- a/src/initialization.jl +++ b/src/initialization.jl @@ -23,4 +23,10 @@ struct OverrideInitData{IProb, UIProb, IProbMap, IProbPmap} the parameter object of the original problem. """ initializeprobpmap::IProbPmap + + function OverrideInitData(initprob::I, update_initprob!::J, initprobmap::K, initprobpmap::L) where {I, J, K, L} + @assert initprob <: Union{NonlinearProblem, NonlinearLeastSquaresProblem} + return new{I, J, K, L}(initprob, update_initprob!, initprobmap, initprobpmap) + end end + diff --git a/src/scimlfunctions.jl b/src/scimlfunctions.jl index a2d5d1388..9f67d60bd 100644 --- a/src/scimlfunctions.jl +++ b/src/scimlfunctions.jl @@ -2483,9 +2483,6 @@ function ODEFunction{iip, specialize}(f; initialization_data, initializeprob, update_initializeprob!, initializeprobmap, initializeprobpmap) - @assert typeof(initdata.initializeprob) <: - Union{Nothing, NonlinearProblem, NonlinearLeastSquaresProblem} - if specialize === NoSpecialize ODEFunction{iip, specialize, Any, Any, Any, Any, @@ -2756,8 +2753,6 @@ function SplitFunction{iip, specialize}(f1, f2; initdata = reconstruct_initialization_data( initialization_data, initializeprob, update_initializeprob!, initializeprobmap, initializeprobpmap) - @assert typeof(initdata.initializeprob) <: - Union{Nothing, NonlinearProblem, NonlinearLeastSquaresProblem} if specialize === NoSpecialize SplitFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, Any, @@ -3445,9 +3440,6 @@ function DAEFunction{iip, specialize}(f; initialization_data, initializeprob, update_initializeprob!, initializeprobmap, initializeprobpmap) - @assert typeof(initdata.initializeprob) <: - Union{Nothing, NonlinearProblem, NonlinearLeastSquaresProblem} - if specialize === NoSpecialize DAEFunction{iip, specialize, Any, Any, Any, Any, Any, Any, Any, Any, @@ -4455,7 +4447,7 @@ end function has_initializeprobpmap(f::AbstractSciMLFunction) __has_initializeprobpmap(f) && f.initialization_data.initializeprobpmap !== nothing end -function has_initialization_data(f::AbstractSciMLFunction) +function has_initialization_data(f) __has_initialization_data(f) && f.initialization_data !== nothing end