Skip to content

Commit

Permalink
cleaned up constraint\!
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcaillau committed Jun 22, 2024
1 parent 0527b06 commit 1409ec8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ function constraint!(
__check_all_set(ocp)
type == :variable && is_fixed(ocp) && throw(UnauthorizedCall("the ocp has no variable" * ", you cannot use constraint! function with type=:variable."))
label constraints_labels(ocp) && throw(UnauthorizedCall("the constraint named " * String(label) * " already exists."))
!isnothing(lb) && !isnothing(ub) && throw(UnauthorizedCall("Calling the constraint! function without any bounds is not authorized."))
isnothing(lb) && isnothing(ub) && throw(UnauthorizedCall("Calling the constraint! function without any bounds is not authorized."))

# bounds
isnothing(lb) && (lb = -Inf*(size(ub,1) == 1 ? 1 : ones(eltype(ub), size(ub,1))))
Expand Down
4 changes: 2 additions & 2 deletions test/test_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ end
@test_throws UnauthorizedCall constraint!(ocp_error, :variable)
@test_throws UnauthorizedCall constraint!(ocp_error, :control, f=dummy, label=:c1)
@test_throws UnauthorizedCall constraint!(ocp_error, :state, rg=1:2:3, label=:c2)
@test_throws UnauthorizedCall constraint!(ocp_error, :state, rg=1:2:3, f=dummy, lb=[0,0], ub=[0,0], label=:c3)
@test_throws UnauthorizedCall constraint!(ocp_error, :state, f=dummy, rg=1:2:3, lb=[0,0], ub=[0,0], label=:c4)
@test_throws IncorrectArgument constraint!(ocp_error, :state, rg=1:2:3, f=dummy, lb=[0,0], ub=[0,0], label=:c3)
@test_throws IncorrectArgument constraint!(ocp_error, :state, f=dummy, rg=1:2:3, lb=[0,0], ub=[0,0], label=:c4)

end

Expand Down

0 comments on commit 1409ec8

Please sign in to comment.