From 25b27be0894eebad688549beb4c0c29129d54c62 Mon Sep 17 00:00:00 2001 From: ErikQQY <2283984853@qq.com> Date: Mon, 2 Oct 2023 00:43:31 +0800 Subject: [PATCH] Fix tests failings for TwoPointBVPFunction Signed-off-by: ErikQQY <2283984853@qq.com> --- src/problems/bvp_problems.jl | 20 ++++++++++---------- src/remake.jl | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/problems/bvp_problems.jl b/src/problems/bvp_problems.jl index 2e9f1feab..8ca00c70d 100644 --- a/src/problems/bvp_problems.jl +++ b/src/problems/bvp_problems.jl @@ -108,7 +108,7 @@ struct BVProblem{uType, tType, isinplace, P, F, BF, PT, K} <: problem_type::PT kwargs::K - @add_kwonly function BVProblem{iip}(f::AbstractBVPFunction{iip, TP}, bc, u0, tspan, + @add_kwonly function BVProblem{iip}(f::AbstractBVPFunction{iip, TP}, u0, tspan, p = NullParameters(); problem_type=nothing, kwargs...) where {iip, TP} _tspan = promote_tspan(tspan) warn_paramtype(p) @@ -119,25 +119,25 @@ struct BVProblem{uType, tType, isinplace, P, F, BF, PT, K} <: else @assert prob_type === problem_type "This indicates incorrect problem type specification! Users should never pass in `problem_type` kwarg, this exists exclusively for internal use." end - return new{typeof(u0), typeof(_tspan), iip, typeof(p), typeof(f), typeof(bc), - typeof(problem_type), typeof(kwargs)}(f, bc, u0, _tspan, p, problem_type, + return new{typeof(u0), typeof(_tspan), iip, typeof(p), typeof(f), typeof(f.bc), + typeof(problem_type), typeof(kwargs)}(f, f.bc, u0, _tspan, p, problem_type, kwargs) end function BVProblem{iip}(f, bc, u0, tspan, p = NullParameters(); kwargs...) where {iip} - BVProblem(BVPFunction{iip}(f, bc), bc, u0, tspan, p; kwargs...) + BVProblem(BVPFunction{iip}(f, bc), u0, tspan, p; kwargs...) end end TruncatedStacktraces.@truncate_stacktrace BVProblem 3 1 2 -function BVProblem(f, bc, u0, tspan, p = NullParameters(); kwargs...) - iip = isinplace(f, 4) - return BVProblem{iip}(BVPFunction{iip}(f, bc), bc, u0, tspan, p; kwargs...) +function BVProblem(f::AbstractBVPFunction, u0, tspan, p = NullParameters(); kwargs...) + return BVProblem{isinplace(f)}(f, u0, tspan, p; kwargs...) end -function BVProblem(f::AbstractBVPFunction, u0, tspan, p = NullParameters(); kwargs...) - return BVProblem{isinplace(f)}(f, f.bc, u0, tspan, p; kwargs...) +function BVProblem(f, bc, u0, tspan, p = NullParameters(); kwargs...) + iip = isinplace(f, 4) + return BVProblem{iip}(BVPFunction{iip}(f, bc), u0, tspan, p; kwargs...) end # This is mostly a fake stuct and isn't used anywhere @@ -157,7 +157,7 @@ end function TwoPointBVProblem(f::AbstractBVPFunction{iip, twopoint}, u0, tspan, p = NullParameters(); kwargs...) where {iip, twopoint} @assert twopoint "`TwoPointBVProblem` can only be used with a `TwoPointBVPFunction`. Instead of using `BVPFunction`, use `TwoPointBVPFunction` or pass a kwarg `twopoint=true` during the construction of the `BVPFunction`." - return BVProblem{iip}(f, f.bc, u0, tspan, p; kwargs...) + return BVProblem{iip}(f, u0, tspan, p; kwargs...) end # Allow previous timeseries solution diff --git a/src/remake.jl b/src/remake.jl index 7bbc6de6a..92fae28f1 100644 --- a/src/remake.jl +++ b/src/remake.jl @@ -308,6 +308,26 @@ function remake(prob::NonlinearProblem; end end +""" + remake(f::AbstractBVPFunction; f = missing, u0 = missing, tspan = missing, + p = missing, noise = missing, noise_rate_prototype = missing, + seed = missing, kwargs = missing, _kwargs...) + +Remake the given `BVPFunction`. +""" +function remake(ff::AbstractBVPFunction{iip, twopoint}; f = missing, bc = missing) where {iip, twopoint} + if f === missing + f = ff.f + end + + if bc === missing + bc = ff.bc + end + + return twopoint ? TwoPointBVPFunction{isinplace(ff)}(f, bc) : BVPFunction{isinplace(ff), false}(f, bc) +end + + # overloaded in MTK to intercept symbolic remake function process_p_u0_symbolic(prob, p, u0) if typeof(prob) <: Union{AbstractDEProblem, OptimizationProblem, NonlinearProblem}