From f1f7e92ee28640b1a4d0ed7a399c6da709199e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 9 Oct 2024 11:18:43 +0200 Subject: [PATCH] Fix dimension of nonlinear function in basic tests --- src/Test/test_basic_constraint.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Test/test_basic_constraint.jl b/src/Test/test_basic_constraint.jl index 6ac1f44b7d..b4e8662fac 100644 --- a/src/Test/test_basic_constraint.jl +++ b/src/Test/test_basic_constraint.jl @@ -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. @@ -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