From 16d6a21c44b7bdef175e819b71d596a5df2fe86a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Thu, 3 Mar 2022 20:33:38 -0500 Subject: [PATCH 1/2] Update to JuMP v0.23 and MOI v1 --- Project.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 88384f8..e97e613 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PolyJuMP" uuid = "ddf597a6-d67e-5340-b84c-e37d84115374" repo = "https://github.com/jump-dev/PolyJuMP.jl.git" -version = "0.5.1" +version = "0.6.0" [deps] JuMP = "4076af6c-e467-56ae-b986-b466b2749572" @@ -14,14 +14,14 @@ MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0" SemialgebraicSets = "8e049039-38e8-557d-ae3a-bc521ccf6204" [compat] -JuMP = "0.22" -MathOptInterface = "0.10" +JuMP = "0.23" +MathOptInterface = "1" MultivariateBases = "0.1.4" MultivariateMoments = "0.3" MultivariatePolynomials = "0.4" -MutableArithmetics = "0.3" +MutableArithmetics = "1" SemialgebraicSets = "0.2" -julia = "1" +julia = "1.6" [extras] DynamicPolynomials = "7c1d4256-1411-5781-91ec-d7bc3513ac07" From 69d7141e5314607cbfbae47bd3baca3d35ecd005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Sat, 5 Mar 2022 11:49:02 -0500 Subject: [PATCH 2/2] Convert printing --- src/constraint.jl | 4 ++-- test/constraint.jl | 10 +++++----- test/testpolymodule.jl | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/constraint.jl b/src/constraint.jl index 49e4b06..ecf8e42 100644 --- a/src/constraint.jl +++ b/src/constraint.jl @@ -10,11 +10,11 @@ struct ZeroPoly <: PolynomialSet end struct NonNegPoly <: PolynomialSet end struct PosDefPolyMatrix <: PolynomialSet end -function JuMP.function_string(::Type{JuMP.REPLMode}, +function JuMP.function_string(::MIME"text/plain", p::MultivariatePolynomials.APL) return sprint(show, MIME"text/plain"(), p) end -function JuMP.function_string(::Type{JuMP.IJuliaMode}, +function JuMP.function_string(::MIME"text/latex", p::MultivariatePolynomials.APL) # `show` prints `$$` around what `_show` prints. return sprint(MultivariatePolynomials._show, MIME"text/latex"(), p) diff --git a/test/constraint.jl b/test/constraint.jl index 6ad9062..55f73e5 100644 --- a/test/constraint.jl +++ b/test/constraint.jl @@ -43,12 +43,12 @@ _canon(model, p::Matrix) = _canon.(model, p) set = set.set end p_canon = _canon(m, p) - expected_str = string(JuMP.function_string(REPLMode, p_canon), ' ', - JuMP._math_symbol(REPLMode, :in), ' ', jump_set) + expected_str = string(JuMP.function_string(MIME"text/plain"(), p_canon), ' ', + JuMP._math_symbol(MIME"text/plain"(), :in), ' ', jump_set) con = JuMP.constraint_object(cref) @test sprint(show, MIME"text/plain"(), cref) == expected_str - expected_str = string("\$\$ ", JuMP.function_string(IJuliaMode, p_canon), ' ', - JuMP._math_symbol(IJuliaMode, :in), ' ', jump_set, + expected_str = string("\$\$ ", JuMP.function_string(MIME"text/latex"(), p_canon), ' ', + JuMP._math_symbol(MIME"text/latex"(), :in), ' ', jump_set, " \$\$") @test sprint(show, MIME"text/latex"(), cref) == expected_str @test set.basis == basis @@ -82,7 +82,7 @@ _canon(model, p::Matrix) = _canon.(model, p) dom = @set x^2 + y^2 == 1 && x^3 + x*y^2 + y >= 1 @testset "Printing" begin - in_sym = JuMP._math_symbol(REPLMode, :in) + in_sym = JuMP._math_symbol(MIME"text/plain"(), :in) eqref = @constraint(m, p == q) @test sprint(show, MIME"text/plain"(), eqref) == "(-α + β)x² + (α - β)xy + (-α)y² $in_sym PolyJuMP.ZeroPoly()" @test sprint(show, MIME"text/latex"(), eqref) == "\$\$ (-α + β)x^{2} + (α - β)xy + (-α)y^{2} \\in PolyJuMP.ZeroPoly() \$\$" diff --git a/test/testpolymodule.jl b/test/testpolymodule.jl index aa1bddf..a85c869 100644 --- a/test/testpolymodule.jl +++ b/test/testpolymodule.jl @@ -106,7 +106,7 @@ end # TODO the function in JuMP should not require the eltype to be # `AbstractJuMPScalar` so that we don't have to define this # These methods are just copy-paste from JuMP/src/print.jl -function JuMP.function_string(::Type{REPLMode}, +function JuMP.function_string(::MIME"text/plain", A::AbstractMatrix{<:AbstractPolynomialLike}) str = sprint(show, MIME"text/plain"(), A) lines = split(str, '\n') @@ -119,7 +119,7 @@ function JuMP.function_string(::Type{REPLMode}, end return join(lines, '\n') end -function JuMP.function_string(print_mode::Type{IJuliaMode}, +function JuMP.function_string(print_mode::MIME"text/latex", A::AbstractMatrix{<:AbstractPolynomialLike}) str = sprint(show, MIME"text/plain"(), A) str = "\\begin{bmatrix}\n"