Skip to content

Commit

Permalink
Throw errors for unsupported keywords (#104)
Browse files Browse the repository at this point in the history
* Throw errors for unsupported keywords

* Fix format
  • Loading branch information
blegat authored Mar 4, 2024
1 parent 68939f2 commit 5ffe3c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/SAGE/SAGE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ function JuMP.build_constraint(
set::Union{Signomials,Polynomials};
kws...,
)
for (key, _) in kws
_error("unsupported keyword argument `$key`.")
end
coefs = PolyJuMP.non_constant_coefficients(p)
monos = MP.monomials(p)
cone = JuMP.moi_set(set, monos)
Expand Down
11 changes: 11 additions & 0 deletions test/sage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ function test_motzkin(x, y, T, solver)
return
end

# See https://github.com/jump-dev/PolyJuMP.jl/issues/102#issuecomment-1888004697
function test_domain(x, y, T, solver)
p = x^3 - x^2 + 2x * y - y^2 + y^3
S = @set x >= 0 && y >= 0 && x + y >= 1
model = Model(solver)
setpolymodule!(model, PolyJuMP.SAGE)
@variable(model, α)
@objective(model, Max, α)
@test_throws ErrorException @constraint(model, c3, p >= α, domain = S)
end

import ECOS
const SOLVERS =
[optimizer_with_attributes(ECOS.Optimizer, MOI.Silent() => true)]
Expand Down

0 comments on commit 5ffe3c9

Please sign in to comment.