From 4df987ca46206e3eb2007892a554549c925a6cfe Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Mon, 29 Jan 2024 13:55:56 +0530 Subject: [PATCH] refactor: remove type-pirated functions moved to SciMLBase --- src/cache.jl | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/src/cache.jl b/src/cache.jl index a7a856ba6..a638fac86 100644 --- a/src/cache.jl +++ b/src/cache.jl @@ -1,40 +1,3 @@ - -function Base.getproperty(cache::SciMLBase.AbstractOptimizationCache, x::Symbol) - if x in (:u0, :p) - return getfield(cache.reinit_cache, x) - end - return getfield(cache, x) -end - -SciMLBase.has_reinit(cache::SciMLBase.AbstractOptimizationCache) = true -function SciMLBase.reinit!(cache::SciMLBase.AbstractOptimizationCache; p = missing, - u0 = missing) - if p === missing && u0 === missing - p, u0 = cache.p, cache.u0 - else # at least one of them has a value - if p === missing - p = cache.p - end - if u0 === missing - u0 = cache.u0 - end - if (eltype(p) <: Pair && !isempty(p)) || (eltype(u0) <: Pair && !isempty(u0)) # one is a non-empty symbolic map - hasproperty(cache.f, :sys) && hasfield(typeof(cache.f.sys), :ps) || - throw(ArgumentError("This cache does not support symbolic maps with `remake`, i.e. it does not have a symbolic origin." * - " Please use `remake` with the `p` keyword argument as a vector of values, paying attention to parameter order.")) - hasproperty(cache.f, :sys) && hasfield(typeof(cache.f.sys), :states) || - throw(ArgumentError("This cache does not support symbolic maps with `remake`, i.e. it does not have a symbolic origin." * - " Please use `remake` with the `u0` keyword argument as a vector of values, paying attention to state order.")) - p, u0 = SciMLBase.process_p_u0_symbolic(cache, p, u0) - end - end - - cache.reinit_cache.p = p - cache.reinit_cache.u0 = u0 - - return cache -end - struct OptimizationCache{F, RC, LB, UB, LC, UC, S, O, D, P, C} <: SciMLBase.AbstractOptimizationCache f::F