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 printing of Interval in LaTeX #3866

Merged
merged 2 commits into from
Nov 4, 2024
Merged

Fix printing of Interval in LaTeX #3866

merged 2 commits into from
Nov 4, 2024

Conversation

blegat
Copy link
Member

@blegat blegat commented Nov 4, 2024

Reproduce it with:

julia> model = Model();

julia> @variable(model, x);

julia> @constraint(model, x in MOI.Interval(0.5, 1.5))
x  [0.5, 1.5]

julia> latex_formulation(model)
$$ \begin{aligned}
\text{feasibility}\\
Error showing value of type JuMP._LatexModel{Model}:
ERROR: MethodError: no method matching _escape_if_scientific(::typeof(mode), ::String)
The function `_escape_if_scientific` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  _escape_if_scientific(::MIME{Symbol("text/latex")}, ::String)
   @ JuMP ~/.julia/dev/JuMP/src/print.jl:73
  _escape_if_scientific(::MIME, ::String)
   @ JuMP ~/.julia/dev/JuMP/src/print.jl:71

Stacktrace:
  [1] _string_round
    @ ~/.julia/dev/JuMP/src/print.jl:87 [inlined]
  [2] in_set_string(::MIME{Symbol("text/latex")}, set::MathOptInterface.Interval{Float64})
    @ JuMP ~/.julia/dev/JuMP/src/print.jl:1058

After the PR:

julia> latex_formulation(model)
$$ \begin{aligned}
\text{feasibility}\\
\text{Subject to} \quad & x \in [0.5, 1.5]\\
\end{aligned} $$

Found by @johnaoga in dionysos-dev/Dionysos.jl#383

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.55%. Comparing base (be7d350) to head (63237e7).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3866   +/-   ##
=======================================
  Coverage   97.55%   97.55%           
=======================================
  Files          44       44           
  Lines        6059     6059           
=======================================
  Hits         5911     5911           
  Misses        148      148           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@odow odow merged commit 139bead into master Nov 4, 2024
11 checks passed
@odow odow deleted the bl/interval_latex branch November 4, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants