Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Oct 7, 2024
1 parent 3001d12 commit 3b0beab
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 50 deletions.
3 changes: 1 addition & 2 deletions src/print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
96 changes: 48 additions & 48 deletions test/test_print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3b0beab

Please sign in to comment.