From d3b680e567dd2d4ce2e1d80933ca49768f3a7fcf Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Wed, 8 Jul 2026 16:16:18 +1200 Subject: [PATCH 1/2] Fix printing of zero-dimensional vector functions --- src/Utilities/print.jl | 2 +- test/Utilities/test_print.jl | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Utilities/print.jl b/src/Utilities/print.jl index c9aff0ea8d..05e7e36b86 100644 --- a/src/Utilities/print.jl +++ b/src/Utilities/print.jl @@ -268,7 +268,7 @@ function _to_string( f::MOI.AbstractVectorFunction, ) rows = map(fi -> _to_string(options, model, fi), scalarize(f)) - max_length = maximum(length.(rows)) + max_length = mapreduce(max, length, rows; init = 0) s = join(map(r -> string("│", rpad(r, max_length), "│"), rows), '\n') return string( "┌", diff --git a/test/Utilities/test_print.jl b/test/Utilities/test_print.jl index a22f12e67c..87e5bc1fc3 100644 --- a/test/Utilities/test_print.jl +++ b/test/Utilities/test_print.jl @@ -762,6 +762,22 @@ function test_print_constraint_name_unsupported() return end +function test_print_zero_dimensional_function() + for f in Any[ + MOI.VectorOfVariables(MOI.VariableIndex[]), + MOI.VectorAffineFunction(MOI.VectorAffineTerm{Float64}[], Float64[]), + MOI.VectorQuadraticFunction( + MOI.VectorQuadraticTerm{Float64}[], + MOI.VectorAffineTerm{Float64}[], + Float64[], + ), + MOI.VectorNonlinearFunction(MOI.ScalarNonlinearFunction[]), + ] + @test sprint(show, f) == "┌┐\n\n└┘" + end + return +end + end TestPrint.runtests() From c35f3100d67441944e2c554a4ff3f58b3c9d3075 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Wed, 8 Jul 2026 16:26:19 +1200 Subject: [PATCH 2/2] Update --- src/Utilities/print.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utilities/print.jl b/src/Utilities/print.jl index 05e7e36b86..87cc0602c9 100644 --- a/src/Utilities/print.jl +++ b/src/Utilities/print.jl @@ -268,7 +268,7 @@ function _to_string( f::MOI.AbstractVectorFunction, ) rows = map(fi -> _to_string(options, model, fi), scalarize(f)) - max_length = mapreduce(max, length, rows; init = 0) + max_length = mapreduce(length, max, rows; init = 0) s = join(map(r -> string("│", rpad(r, max_length), "│"), rows), '\n') return string( "┌",