Skip to content

Commit

Permalink
Fix dimension of nonlinear function in basic tests (#2555)
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat authored Oct 9, 2024
1 parent fe76b33 commit 6126271
Showing 1 changed file with 5 additions and 5 deletions.
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

0 comments on commit 6126271

Please sign in to comment.