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 dimension of nonlinear function in basic tests #2555

Merged
merged 1 commit into from
Oct 9, 2024
Merged
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
10 changes: 5 additions & 5 deletions src/Test/test_basic_constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ function _function(
::Type{MOI.VectorNonlinearFunction},
x::Vector{MOI.VariableIndex},
) where {T}
f = MOI.ScalarNonlinearFunction(
:+,
Any[MOI.ScalarNonlinearFunction(:^, Any[xi, 2]) for xi in x],
)
return MOI.VectorNonlinearFunction([f; x])
f = _function(T, MOI.ScalarNonlinearFunction, x)
# The length of the function should be equal to the length of `x`
# so we drop `x[1]`
return MOI.VectorNonlinearFunction([f; x[2:end]])
end

# Default fallback.
Expand Down Expand Up @@ -216,6 +215,7 @@ function _basic_constraint_test_helper(
N = MOI.dimension(set)
x = MOI.add_variables(model, N)
constraint_function = _function(T, UntypedF, x)
@assert MOI.output_dimension(constraint_function) == N
F, S = typeof(constraint_function), typeof(set)
###
### Test MOI.supports_constraint
Expand Down
Loading