Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests failings for TwoPointBVPFunction #517

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the bc out here at all? Isn't it in the BVPFunction?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avik-pal is it actually needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bc was kept outside similar to the SDEProblem interface carrying around the g outside (I think?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was just fixed in the v2.0. I thought this was fixed in the v2.0 as well 😅. Fix and slip it in ASAP.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The modifications in BVProblem is similiar to SDEProblem, just try to make them consistent

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SDEProblem is still carrying around g

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, SDEProblem is still carrying g, so in this way I think we can still use prob.g to directly access g

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to remove g in the problem struct?

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 @@
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 @@
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
Loading