Skip to content

Commit

Permalink
Fix tests failings for TwoPointBVPFunction
Browse files Browse the repository at this point in the history
Signed-off-by: ErikQQY <[email protected]>
  • Loading branch information
ErikQQY committed Oct 1, 2023
1 parent 75b1925 commit 25b27be
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/problems/bvp_problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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...)

Check warning on line 128 in src/problems/bvp_problems.jl

View check run for this annotation

Codecov / codecov/patch

src/problems/bvp_problems.jl#L128

Added line #L128 was not covered by tests
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...)

Check warning on line 135 in src/problems/bvp_problems.jl

View check run for this annotation

Codecov / codecov/patch

src/problems/bvp_problems.jl#L134-L135

Added lines #L134 - L135 were not covered by tests
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
Expand All @@ -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...)

Check warning on line 160 in src/problems/bvp_problems.jl

View check run for this annotation

Codecov / codecov/patch

src/problems/bvp_problems.jl#L160

Added line #L160 was not covered by tests
end

# Allow previous timeseries solution
Expand Down
20 changes: 20 additions & 0 deletions src/remake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 324 in src/remake.jl

View check run for this annotation

Codecov / codecov/patch

src/remake.jl#L324

Added line #L324 was not covered by tests
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}
Expand Down

0 comments on commit 25b27be

Please sign in to comment.