From 3b0beabbbb0fe72266cbcc4f1ff99c490ecf3c73 Mon Sep 17 00:00:00 2001 From: odow Date: Mon, 7 Oct 2024 15:02:49 +1300 Subject: [PATCH] Update --- src/print.jl | 3 +- test/test_print.jl | 96 +++++++++++++++++++++++----------------------- 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/src/print.jl b/src/print.jl index 657facddaf2..9be80794bb4 100644 --- a/src/print.jl +++ b/src/print.jl @@ -600,8 +600,7 @@ function nonlinear_constraint_string( body = nonlinear_expr_string(model, mode, constraint.expression) lhs = _set_lhs(constraint.set) rhs = _set_rhs(constraint.set) - output = - "$body $(_math_symbol(mode, rhs[1])) $(_string_round(mode, rhs[2]))" + output = "$body $(_math_symbol(mode, rhs[1])) $(_string_round(mode, rhs[2]))" if lhs === nothing return output end diff --git a/test/test_print.jl b/test/test_print.jl index 5d5041c3ec3..c51bac985a1 100644 --- a/test/test_print.jl +++ b/test/test_print.jl @@ -888,22 +888,22 @@ end function test_print_complex_string_round() for (test, result) in Any[ - 1.0 + 0.0im => "1", - -1.0 + 0.0im => "-1", - 1.0 - 0.0im => "1", - -1.0 - 0.0im => "-1", - 0.0 + 1.0im => "im", - -0.0 + 1.0im => "im", - 0.0 - 1.0im => "-im", - -0.0 - 1.0im => "-im", - 1.0 + 2.0im => "(1 + 2im)", - 1.0 - 2.0im => "(1 - 2im)", - -1.0 + 2.0im => "(-1 + 2im)", - -1.0 - 2.0im => "(-1 - 2im)", - 1.0 + 1.0im => "(1 + im)", - 1.0 - 1.0im => "(1 - im)", - -1.0 + 1.0im => "(-1 + im)", - -1.0 - 1.0im => "(-1 - im)", + 1.0+0.0im=>"1", + -1.0+0.0im=>"-1", + 1.0-0.0im=>"1", + -1.0-0.0im=>"-1", + 0.0+1.0im=>"im", + -0.0+1.0im=>"im", + 0.0-1.0im=>"-im", + -0.0-1.0im=>"-im", + 1.0+2.0im=>"(1 + 2im)", + 1.0-2.0im=>"(1 - 2im)", + -1.0+2.0im=>"(-1 + 2im)", + -1.0-2.0im=>"(-1 - 2im)", + 1.0+1.0im=>"(1 + im)", + 1.0-1.0im=>"(1 - im)", + -1.0+1.0im=>"(-1 + im)", + -1.0-1.0im=>"(-1 - im)", ] @test JuMP._string_round(MIME("text/plain"), test) == result end @@ -912,38 +912,38 @@ end function test_print_huge_integer_string_round() for (test, result) in Any[ - -1 + Float32(typemax(Int32)) => "2147483648", - -1 + Float32(typemin(Int32)) => "-2147483648", - -1 + Float64(typemax(Int32)) => "2147483646", - -1 + Float64(typemin(Int32)) => "-2147483649", - Float32(typemax(Int32)) => "2147483648", - Float32(typemin(Int32)) => "-2147483648", - Float64(typemax(Int32)) => "2147483647", - Float64(typemin(Int32)) => "-2147483648", - 1 + Float32(typemax(Int32)) => "2147483648", - 1 + Float32(typemin(Int32)) => "-2147483648", - 1 + Float64(typemax(Int32)) => "2147483648", - 1 + Float64(typemin(Int32)) => "-2147483647", - 2 * Float32(typemax(Int32)) => "4294967296", - 2 * Float32(typemin(Int32)) => "-4294967296", - 2 * Float64(typemax(Int32)) => "4294967294", - 2 * Float64(typemin(Int32)) => "-4294967296", - -1 + Float32(typemax(Int64)) => "9.223372e18", - -1 + Float32(typemin(Int64)) => "-9223372036854775808", - -1 + Float64(typemax(Int64)) => "9.223372036854776e18", - -1 + Float64(typemin(Int64)) => "-9223372036854775808", - Float32(typemax(Int64)) => "9.223372e18", - Float32(typemin(Int64)) => "-9223372036854775808", - Float64(typemax(Int64)) => "9.223372036854776e18", - Float64(typemin(Int64)) => "-9223372036854775808", - 1 + Float32(typemax(Int64)) => "9.223372e18", - 1 + Float32(typemin(Int64)) => "-9223372036854775808", - 1 + Float64(typemax(Int64)) => "9.223372036854776e18", - 1 + Float64(typemin(Int64)) => "-9223372036854775808", - 2 * Float32(typemax(Int64)) => "1.8446744e19", - 2 * Float32(typemin(Int64)) => "-1.8446744e19", - 2 * Float64(typemax(Int64)) => "1.8446744073709552e19", - 2 * Float64(typemin(Int64)) => "-1.8446744073709552e19", + -1+Float32(typemax(Int32))=>"2147483648", + -1+Float32(typemin(Int32))=>"-2147483648", + -1+Float64(typemax(Int32))=>"2147483646", + -1+Float64(typemin(Int32))=>"-2147483649", + Float32(typemax(Int32))=>"2147483648", + Float32(typemin(Int32))=>"-2147483648", + Float64(typemax(Int32))=>"2147483647", + Float64(typemin(Int32))=>"-2147483648", + 1+Float32(typemax(Int32))=>"2147483648", + 1+Float32(typemin(Int32))=>"-2147483648", + 1+Float64(typemax(Int32))=>"2147483648", + 1+Float64(typemin(Int32))=>"-2147483647", + 2*Float32(typemax(Int32))=>"4294967296", + 2*Float32(typemin(Int32))=>"-4294967296", + 2*Float64(typemax(Int32))=>"4294967294", + 2*Float64(typemin(Int32))=>"-4294967296", + -1+Float32(typemax(Int64))=>"9.223372e18", + -1+Float32(typemin(Int64))=>"-9223372036854775808", + -1+Float64(typemax(Int64))=>"9.223372036854776e18", + -1+Float64(typemin(Int64))=>"-9223372036854775808", + Float32(typemax(Int64))=>"9.223372e18", + Float32(typemin(Int64))=>"-9223372036854775808", + Float64(typemax(Int64))=>"9.223372036854776e18", + Float64(typemin(Int64))=>"-9223372036854775808", + 1+Float32(typemax(Int64))=>"9.223372e18", + 1+Float32(typemin(Int64))=>"-9223372036854775808", + 1+Float64(typemax(Int64))=>"9.223372036854776e18", + 1+Float64(typemin(Int64))=>"-9223372036854775808", + 2*Float32(typemax(Int64))=>"1.8446744e19", + 2*Float32(typemin(Int64))=>"-1.8446744e19", + 2*Float64(typemax(Int64))=>"1.8446744073709552e19", + 2*Float64(typemin(Int64))=>"-1.8446744073709552e19", ] @test JuMP._string_round(MIME("text/plain"), test) == result end