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 bcresid_prototype in TwoPointBVPFunction #522

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
4 changes: 2 additions & 2 deletions src/scimlfunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4067,8 +4067,8 @@
end

if twopoint
if iip && (bcresid_prototype === nothing || length(bcresid_prototype) != 2)
error("bcresid_prototype must be a tuple / indexable collection of length 2 for a inplace TwoPointBVPFunction")
if iip && bcresid_prototype !== nothing
Copy link
Member

Choose a reason for hiding this comment

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

how is this different?

Copy link
Member Author

@ErikQQY ErikQQY Oct 8, 2023

Choose a reason for hiding this comment

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

I think when we are defining a TwoPointBVPFunction, bcresid_prototype can be defined as nothing right?

Copy link
Member

Choose a reason for hiding this comment

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

no it cannot, otherwise how would you know how many conditions are on the left vs right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I see, thanks

@assert length(bcresid_prototype) == 2 error("bcresid_prototype must be a tuple / indexable collection of length 2 for an inplace TwoPointBVPFunction")

Check warning on line 4071 in src/scimlfunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/scimlfunctions.jl#L4070-L4071

Added lines #L4070 - L4071 were not covered by tests
end
if bcresid_prototype !== nothing && length(bcresid_prototype) == 2
bcresid_prototype = ArrayPartition(first(bcresid_prototype),
Expand Down
8 changes: 8 additions & 0 deletions test/function_building_error_messages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,14 @@ BVPFunction(bfiip, bciip, vjp = bvjp)

@test_throws SciMLBase.NonconformingFunctionsError BVPFunction(bfoop, bciip, vjp = bvjp)

# TwoPointBVPFunction

tpbvpf(du, u, p, t) = du .= u
tpbvpbca(resa, ua, p) = resa .= ua
tpbvpbcb(resb, ub, p) = resb .= ub
SciMLBase.TwoPointBVPFunction(tpbvpf, (tpbvpbca, tpbvpbcb))
@test_throws ErrorException SciMLBase.TwoPointBVPFunction(tpbvpf, (tpbvpbca, tpbvpbcb), bcresid_prototype = (1, 1, 1))

# IntegralFunction

ioop(u, p) = p * u
Expand Down
Loading