Skip to content

Rename isempty -> is_empty #506

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

Merged
merged 1 commit into from
Aug 27, 2018
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
4 changes: 2 additions & 2 deletions src/Bridges/bridgeoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ bridge(b::AbstractBridgeOptimizer, ci::CI) = b.bridges[ci]
MOI.optimize!(b::AbstractBridgeOptimizer) = MOI.optimize!(b.model)
# By convention, the model should be stored in a `model` field

function MOI.isempty(b::AbstractBridgeOptimizer)
return isempty(b.bridges) && MOI.isempty(b.model)
function MOI.is_empty(b::AbstractBridgeOptimizer)
return isempty(b.bridges) && MOI.is_empty(b.model)
end
function MOI.empty!(b::AbstractBridgeOptimizer)
MOI.empty!(b.model)
Expand Down
4 changes: 2 additions & 2 deletions src/MathOptInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ variable index by name: `get(model, VariableIndex, "name")`.
function read_from_file end

"""
isempty(model::ModelLike)
is_empty(model::ModelLike)

Returns `false` if the `model` has any model attribute set or has any variables or constraints.
Note that an empty model can have optimizer attributes set.
"""
function isempty end
function is_empty end

"""
empty!(model::ModelLike)
Expand Down
16 changes: 8 additions & 8 deletions src/Test/UnitTests/objectives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Test setting objective sense to MaxSense.
"""
function max_sense(model::MOI.ModelLike, config::TestConfig)
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
@test MOI.supports(model, MOI.ObjectiveSense())
MOI.set(model, MOI.ObjectiveSense(), MOI.MaxSense)
@test MOI.get(model, MOI.ObjectiveSense()) == MOI.MaxSense
Expand All @@ -35,7 +35,7 @@ Test setting objective sense to MinSense.
"""
function min_sense(model::MOI.ModelLike, config::TestConfig)
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
@test MOI.supports(model, MOI.ObjectiveSense())
MOI.set(model, MOI.ObjectiveSense(), MOI.MinSense)
@test MOI.get(model, MOI.ObjectiveSense()) == MOI.MinSense
Expand All @@ -49,7 +49,7 @@ Test setting objective sense to FeasibilitySense.
"""
function feasibility_sense(model::MOI.ModelLike, config::TestConfig)
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
@test MOI.supports(model, MOI.ObjectiveSense())
MOI.set(model, MOI.ObjectiveSense(), MOI.FeasibilitySense)
@test MOI.get(model, MOI.ObjectiveSense()) == MOI.FeasibilitySense
Expand All @@ -63,7 +63,7 @@ Test get objective function.
"""
function get_objective_function(model::MOI.ModelLike, config::TestConfig)
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
obj_attr = MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}()
@test MOI.supports(model, obj_attr)
MOIU.loadfromstring!(model,"""
Expand Down Expand Up @@ -91,7 +91,7 @@ correctly.
function solve_constant_obj(model::MOI.ModelLike, config::TestConfig)
atol, rtol = config.atol, config.rtol
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
MOIU.loadfromstring!(model,"""
variables: x
minobjective: 2.0x + 1.0
Expand All @@ -118,7 +118,7 @@ correctly.
function solve_blank_obj(model::MOI.ModelLike, config::TestConfig)
atol, rtol = config.atol, config.rtol
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
MOIU.loadfromstring!(model,"""
variables: x
minobjective: 0.0x + 0.0
Expand All @@ -145,7 +145,7 @@ correctly.
function solve_singlevariable_obj(model::MOI.ModelLike, config::TestConfig)
atol, rtol = config.atol, config.rtol
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
MOIU.loadfromstring!(model,"""
variables: x
minobjective: x
Expand Down Expand Up @@ -251,7 +251,7 @@ solves correctly.
"""
function solve_duplicate_terms_obj(model::MOI.ModelLike, config::TestConfig)
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
x = MOI.add_variable(model)
c = MOI.add_constraint(model, MOI.SingleVariable(x), MOI.GreaterThan(1.0))
MOI.set(model, MOI.ObjectiveSense(), MOI.MinSense)
Expand Down
8 changes: 4 additions & 4 deletions src/Test/UnitTests/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Test a variety of edge cases related to the ObjectiveBound attribute.
function solve_objbound_edge_cases(model::MOI.ModelLike, config::TestConfig)
@testset "Min IP with constant" begin
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
MOIU.loadfromstring!(model, """
variables: x
minobjective: 2.0x + -1.0
Expand All @@ -25,7 +25,7 @@ function solve_objbound_edge_cases(model::MOI.ModelLike, config::TestConfig)

@testset "Max IP with constant" begin
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
MOIU.loadfromstring!(model, """
variables: x
maxobjective: 2.0x + 1.0
Expand All @@ -44,7 +44,7 @@ function solve_objbound_edge_cases(model::MOI.ModelLike, config::TestConfig)

@testset "Min LP with constant" begin
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
MOIU.loadfromstring!(model, """
variables: x
minobjective: 2.0x + -1.0
Expand All @@ -62,7 +62,7 @@ function solve_objbound_edge_cases(model::MOI.ModelLike, config::TestConfig)

@testset "Max LP with constant" begin
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
MOIU.loadfromstring!(model, """
variables: x
maxobjective: 2.0x + 1.0
Expand Down
20 changes: 10 additions & 10 deletions src/Test/UnitTests/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Test adding a single variable.
"""
function add_variable(model::MOI.ModelLike, config::TestConfig)
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
@test MOI.get(model, MOI.NumberOfVariables()) == 0
v = MOI.add_variable(model)
@test MOI.get(model, MOI.NumberOfVariables()) == 1
Expand All @@ -38,7 +38,7 @@ Test adding multiple variables.
"""
function add_variables(model::MOI.ModelLike, config::TestConfig)
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
@test MOI.get(model, MOI.NumberOfVariables()) == 0
v = MOI.add_variables(model, 2)
@test MOI.get(model, MOI.NumberOfVariables()) == 2
Expand All @@ -52,7 +52,7 @@ Tess adding, and then deleting, a single variable.
"""
function delete_variable(model::MOI.ModelLike, config::TestConfig)
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
@test MOI.get(model, MOI.NumberOfVariables()) == 0
v = MOI.add_variable(model)
@test MOI.get(model, MOI.NumberOfVariables()) == 1
Expand All @@ -68,7 +68,7 @@ Test adding, and then deleting, multiple variables.
"""
function delete_variables(model::MOI.ModelLike, config::TestConfig)
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
@test MOI.get(model, MOI.NumberOfVariables()) == 0
v = MOI.add_variables(model, 2)
@test MOI.get(model, MOI.NumberOfVariables()) == 2
Expand Down Expand Up @@ -137,7 +137,7 @@ and if `config.duals=true`, check that the dual is computed correctly.
function solve_with_upperbound(model::MOI.ModelLike, config::TestConfig)
atol, rtol = config.atol, config.rtol
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
MOIU.loadfromstring!(model,"""
variables: x
maxobjective: 2.0x
Expand Down Expand Up @@ -165,7 +165,7 @@ and if `config.duals=true`, check that the dual is computed correctly.
function solve_with_lowerbound(model::MOI.ModelLike, config::TestConfig)
atol, rtol = config.atol, config.rtol
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
MOIU.loadfromstring!(model,"""
variables: x
minobjective: 2.0x
Expand All @@ -192,7 +192,7 @@ Test a variety of edge cases related to binary and integer variables.
function solve_integer_edge_cases(model::MOI.ModelLike, config::TestConfig)
@testset "integer with lower bound" begin
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
MOIU.loadfromstring!(model,"""
variables: x
minobjective: 2.0x
Expand All @@ -207,7 +207,7 @@ function solve_integer_edge_cases(model::MOI.ModelLike, config::TestConfig)
end
@testset "integer with upper bound" begin
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
MOIU.loadfromstring!(model,"""
variables: x
minobjective: -2.0x
Expand All @@ -223,7 +223,7 @@ function solve_integer_edge_cases(model::MOI.ModelLike, config::TestConfig)

@testset "binary with upper" begin
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
MOIU.loadfromstring!(model,"""
variables: x
minobjective: -2.0x
Expand All @@ -239,7 +239,7 @@ function solve_integer_edge_cases(model::MOI.ModelLike, config::TestConfig)

@testset "binary with 0 upper" begin
MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)
MOIU.loadfromstring!(model,"""
variables: x
minobjective: 1.0x
Expand Down
38 changes: 19 additions & 19 deletions src/Test/contconic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function _lin1test(model::MOI.ModelLike, config::TestConfig, vecofvars::Bool)
@test MOI.supports_constraint(model, MOI.VectorAffineFunction{Float64}, MOI.Zeros)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

v = MOI.add_variables(model, 3)
@test MOI.get(model, MOI.NumberOfVariables()) == 3
Expand Down Expand Up @@ -105,7 +105,7 @@ function _lin2test(model::MOI.ModelLike, config::TestConfig, vecofvars::Bool)
@test MOI.supports_constraint(model, MOI.VectorAffineFunction{Float64}, MOI.Zeros)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

x,y,z,s = MOI.add_variables(model, 4)
@test MOI.get(model, MOI.NumberOfVariables()) == 4
Expand Down Expand Up @@ -190,7 +190,7 @@ function lin3test(model::MOI.ModelLike, config::TestConfig)
@test MOI.supports_constraint(model, MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

x = MOI.add_variable(model)

Expand Down Expand Up @@ -238,7 +238,7 @@ function lin4test(model::MOI.ModelLike, config::TestConfig)
@test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.Nonpositives)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

x = MOI.add_variable(model)

Expand Down Expand Up @@ -295,7 +295,7 @@ function _soc1test(model::MOI.ModelLike, config::TestConfig, vecofvars::Bool)
@test MOI.supports_constraint(model, MOI.VectorOfVariables,MOI.SecondOrderCone)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

x,y,z = MOI.add_variables(model, 3)

Expand Down Expand Up @@ -370,7 +370,7 @@ function _soc2test(model::MOI.ModelLike, config::TestConfig, nonneg::Bool)
@test MOI.supports_constraint(model, MOI.VectorAffineFunction{Float64},MOI.SecondOrderCone)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

x,y,t = MOI.add_variables(model, 3)

Expand Down Expand Up @@ -441,7 +441,7 @@ function soc3test(model::MOI.ModelLike, config::TestConfig)
@test MOI.supports_constraint(model, MOI.VectorAffineFunction{Float64},MOI.SecondOrderCone)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

x,y = MOI.add_variables(model, 2)

Expand Down Expand Up @@ -490,7 +490,7 @@ function soc4test(model::MOI.ModelLike, config::TestConfig)
@test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.SecondOrderCone)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

x = MOI.add_variables(model, 5)

Expand Down Expand Up @@ -561,7 +561,7 @@ function _rotatedsoc1test(model::MOI.ModelLike, config::TestConfig, abvars::Bool
end

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

x = MOI.add_variables(model, 2)
if abvars
Expand Down Expand Up @@ -650,7 +650,7 @@ function rotatedsoc2test(model::MOI.ModelLike, config::TestConfig)
@test MOI.supports_constraint(model, MOI.VectorOfVariables,MOI.RotatedSecondOrderCone)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

x = MOI.add_variables(model, 3)

Expand Down Expand Up @@ -717,7 +717,7 @@ function rotatedsoc3test(model::MOI.ModelLike, config::TestConfig; n=2, ub=3.0)
@test MOI.supports_constraint(model, MOI.VectorAffineFunction{Float64}, MOI.RotatedSecondOrderCone)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

x = MOI.add_variables(model, n)
u = MOI.add_variable(model)
Expand Down Expand Up @@ -817,7 +817,7 @@ function _geomean1test(model::MOI.ModelLike, config::TestConfig, vecofvars, n=3)
@test MOI.supports_constraint(model, MOI.ScalarAffineFunction{Float64}, MOI.LessThan{Float64})

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

t = MOI.add_variable(model)
x = MOI.add_variables(model, n)
Expand Down Expand Up @@ -879,7 +879,7 @@ function _exp1test(model::MOI.ModelLike, config::TestConfig, vecofvars::Bool)
@test MOI.supports_constraint(model, MOI.ScalarAffineFunction{Float64}, MOI.EqualTo{Float64})

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

v = MOI.add_variables(model, 3)
@test MOI.get(model, MOI.NumberOfVariables()) == 3
Expand Down Expand Up @@ -944,7 +944,7 @@ function exp2test(model::MOI.ModelLike, config::TestConfig)
@test MOI.supports_constraint(model, MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

v = MOI.add_variables(model, 9)
@test MOI.get(model, MOI.NumberOfVariables()) == 9
Expand Down Expand Up @@ -1009,7 +1009,7 @@ function exp3test(model::MOI.ModelLike, config::TestConfig)
@test MOI.supports_constraint(model, MOI.VectorAffineFunction{Float64}, MOI.ExponentialCone)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

x = MOI.add_variable(model)
y = MOI.add_variable(model)
Expand Down Expand Up @@ -1079,7 +1079,7 @@ function _psd0test(model::MOI.ModelLike, vecofvars::Bool, psdcone, config::TestC
@test MOI.supports_constraint(model, MOI.ScalarAffineFunction{Float64}, MOI.EqualTo{Float64})

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

X = MOI.add_variables(model, square ? 4 : 3)
@test MOI.get(model, MOI.NumberOfVariables()) == (square ? 4 : 3)
Expand Down Expand Up @@ -1213,7 +1213,7 @@ function _psd1test(model::MOI.ModelLike, vecofvars::Bool, psdcone, config::TestC
@test MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.SecondOrderCone)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

X = MOI.add_variables(model, square ? 9 : 6)
@test MOI.get(model, MOI.NumberOfVariables()) == (square ? 9 : 6)
Expand Down Expand Up @@ -1293,7 +1293,7 @@ function psdt2test(model::MOI.ModelLike, config::TestConfig)
@test MOI.supports_constraint(model, MOI.ScalarAffineFunction{Float64}, MOI.EqualTo{Float64})

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

x = MOI.add_variables(model, 7)
@test MOI.get(model, MOI.NumberOfVariables()) == 7
Expand Down Expand Up @@ -1395,7 +1395,7 @@ function _det1test(model::MOI.ModelLike, config::TestConfig, vecofvars::Bool, de
@test MOI.supports_constraint(model, MOI.VectorAffineFunction{Float64}, MOI.Nonnegatives)

MOI.empty!(model)
@test MOI.isempty(model)
@test MOI.is_empty(model)

t = MOI.add_variable(model)
@test MOI.get(model, MOI.NumberOfVariables()) == 1
Expand Down
Loading