Skip to content

Commit

Permalink
Fix printing (#193)
Browse files Browse the repository at this point in the history
* Fix printing

* Fix coefficient
  • Loading branch information
odow authored Apr 22, 2021
1 parent 0416679 commit 4311ef9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
ComplexOptInterface = "0.0.2"
DataStructures = "0.18"
DynamicPolynomials = "0.3.6"
JuMP = "0.21"
JuMP = "0.21.7"
MathOptInterface = "0.9.18"
MultivariateBases = "0.1.2"
MultivariateMoments = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion examples/scaled_perm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ end
Base.:^(p::ScaledPerm, k::Integer) = Base.power_by_squaring(p, k)

function SymbolicWedderburn.permutation(ehom::SymbolicWedderburn.ExtensionHomomorphism{<:AbstractMonomial}, terms::Vector{<:AbstractTerm})
return ScaledPerm([ehom[monomial(term)] => coefficient(term) for term in terms])
return ScaledPerm([ehom[monomial(term)] => MP.coefficient(term) for term in terms])
end
10 changes: 5 additions & 5 deletions test/constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ end
@variable(model, a)
cref = @constraint(model, a * x^2 >= 1)
@test sprint(show, MIME"text/plain"(), cref) == "(a)x² + (-1) is SOS"
@test sprint(show, MIME"text/latex"(), cref) == "\$ (a)x^{2} + (-1) \\text{ is SOS} \$"
@test sprint(show, MIME"text/latex"(), cref) == "\$\$ (a)x^{2} + (-1) \\text{ is SOS} \$\$"
sdref = @constraint(model, a * x^2 in SDSOSCone())
@test sprint(show, MIME"text/plain"(), sdref) == "(a)x² is SDSOS"
@test sprint(show, MIME"text/latex"(), sdref) == "\$ (a)x^{2} \\text{ is SDSOS} \$"
@test sprint(show, MIME"text/latex"(), sdref) == "\$\$ (a)x^{2} \\text{ is SDSOS} \$\$"
dref = @constraint(model, a * x^2 in DSOSCone())
@test sprint(show, MIME"text/plain"(), dref) == "(a)x² is DSOS"
@test sprint(show, MIME"text/latex"(), dref) == "\$ (a)x^{2} \\text{ is DSOS} \$"
@test sprint(show, MIME"text/latex"(), dref) == "\$\$ (a)x^{2} \\text{ is DSOS} \$\$"
for sparsity in [NoSparsity(), VariableSparsity()]
cref_fix = @constraint(model, a * x^2 >= 1, domain = (@set x == 1), sparsity = sparsity)
@test sprint(show, MIME"text/plain"(), cref_fix) == "(a)x² + (-1) is SOS"
@test sprint(show, MIME"text/latex"(), cref_fix) == "\$ (a)x^{2} + (-1) \\text{ is SOS} \$"
@test sprint(show, MIME"text/latex"(), cref_fix) == "\$\$ (a)x^{2} + (-1) \\text{ is SOS} \$\$"
cref_fix = @constraint(model, a * x^2 >= 1, domain = (@set x >= 1), sparsity = sparsity)
@test sprint(show, MIME"text/plain"(), cref_fix) == "(a)x² + (-1) is SOS"
@test sprint(show, MIME"text/latex"(), cref_fix) == "\$ (a)x^{2} + (-1) \\text{ is SOS} \$"
@test sprint(show, MIME"text/latex"(), cref_fix) == "\$\$ (a)x^{2} + (-1) \\text{ is SOS} \$\$"
end
end

0 comments on commit 4311ef9

Please sign in to comment.