Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix text/latex printing of Interval sets #3537

Merged
merged 2 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ end

function in_set_string(::MIME"text/latex", set::MOI.Interval)
lower, upper = _string_round(set.lower), _string_round(set.upper)
return string("\\in \\[", lower, ", ", upper, "\\]")
return string("\\in [", lower, ", ", upper, "]")
end

function in_set_string(mode::MIME"text/plain", set::MOI.Interval)
Expand Down
8 changes: 6 additions & 2 deletions test/test_print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,7 @@ function test_extension_printing_scalaraffinefunction_constraints(
@test sprint(show, "text/latex", linear_le) == "\$\$ x \\leq 1 \$\$"
@test sprint(show, "text/latex", linear_ge) == "\$\$ x \\geq 1 \$\$"
@test sprint(show, "text/latex", linear_eq) == "\$\$ x = 1 \$\$"
@test sprint(show, "text/latex", linear_range) ==
"\$\$ x \\in \\[-1, 1\\] \$\$"
@test sprint(show, "text/latex", linear_range) == "\$\$ x \\in [-1, 1] \$\$"
@test sprint(show, "text/latex", linear_noname) == "\$\$ x \\leq 1 \$\$"
return
end
Expand Down Expand Up @@ -963,4 +962,9 @@ function test_print_model_with_huge_integers()
return
end

function test_print_text_latex_interval_set()
@test in_set_string(MIME("text/latex"), MOI.Interval(1, 2)) == "\\in [1, 2]"
return
end

end
Loading