Skip to content

Commit 6126271

Browse files
authored
Fix dimension of nonlinear function in basic tests (#2555)
1 parent fe76b33 commit 6126271

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Test/test_basic_constraint.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,10 @@ function _function(
8282
::Type{MOI.VectorNonlinearFunction},
8383
x::Vector{MOI.VariableIndex},
8484
) where {T}
85-
f = MOI.ScalarNonlinearFunction(
86-
:+,
87-
Any[MOI.ScalarNonlinearFunction(:^, Any[xi, 2]) for xi in x],
88-
)
89-
return MOI.VectorNonlinearFunction([f; x])
85+
f = _function(T, MOI.ScalarNonlinearFunction, x)
86+
# The length of the function should be equal to the length of `x`
87+
# so we drop `x[1]`
88+
return MOI.VectorNonlinearFunction([f; x[2:end]])
9089
end
9190

9291
# Default fallback.
@@ -216,6 +215,7 @@ function _basic_constraint_test_helper(
216215
N = MOI.dimension(set)
217216
x = MOI.add_variables(model, N)
218217
constraint_function = _function(T, UntypedF, x)
218+
@assert MOI.output_dimension(constraint_function) == N
219219
F, S = typeof(constraint_function), typeof(set)
220220
###
221221
### Test MOI.supports_constraint

0 commit comments

Comments
 (0)