Skip to content

Commit 6a0fce1

Browse files
authored
Merge pull request #506 from JuliaOpt/bl/renameisempty
Rename isempty -> is_empty
2 parents ec19690 + 4fc7467 commit 6a0fce1

19 files changed

+110
-109
lines changed

src/Bridges/bridgeoptimizer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ bridge(b::AbstractBridgeOptimizer, ci::CI) = b.bridges[ci]
7373
MOI.optimize!(b::AbstractBridgeOptimizer) = MOI.optimize!(b.model)
7474
# By convention, the model should be stored in a `model` field
7575

76-
function MOI.isempty(b::AbstractBridgeOptimizer)
77-
return isempty(b.bridges) && MOI.isempty(b.model)
76+
function MOI.is_empty(b::AbstractBridgeOptimizer)
77+
return isempty(b.bridges) && MOI.is_empty(b.model)
7878
end
7979
function MOI.empty!(b::AbstractBridgeOptimizer)
8080
MOI.empty!(b.model)

src/MathOptInterface.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ variable index by name: `get(model, VariableIndex, "name")`.
5858
function read_from_file end
5959

6060
"""
61-
isempty(model::ModelLike)
61+
is_empty(model::ModelLike)
6262
6363
Returns `false` if the `model` has any model attribute set or has any variables or constraints.
6464
Note that an empty model can have optimizer attributes set.
6565
"""
66-
function isempty end
66+
function is_empty end
6767

6868
"""
6969
empty!(model::ModelLike)

src/Test/UnitTests/objectives.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Test setting objective sense to MaxSense.
2121
"""
2222
function max_sense(model::MOI.ModelLike, config::TestConfig)
2323
MOI.empty!(model)
24-
@test MOI.isempty(model)
24+
@test MOI.is_empty(model)
2525
@test MOI.supports(model, MOI.ObjectiveSense())
2626
MOI.set(model, MOI.ObjectiveSense(), MOI.MaxSense)
2727
@test MOI.get(model, MOI.ObjectiveSense()) == MOI.MaxSense
@@ -35,7 +35,7 @@ Test setting objective sense to MinSense.
3535
"""
3636
function min_sense(model::MOI.ModelLike, config::TestConfig)
3737
MOI.empty!(model)
38-
@test MOI.isempty(model)
38+
@test MOI.is_empty(model)
3939
@test MOI.supports(model, MOI.ObjectiveSense())
4040
MOI.set(model, MOI.ObjectiveSense(), MOI.MinSense)
4141
@test MOI.get(model, MOI.ObjectiveSense()) == MOI.MinSense
@@ -49,7 +49,7 @@ Test setting objective sense to FeasibilitySense.
4949
"""
5050
function feasibility_sense(model::MOI.ModelLike, config::TestConfig)
5151
MOI.empty!(model)
52-
@test MOI.isempty(model)
52+
@test MOI.is_empty(model)
5353
@test MOI.supports(model, MOI.ObjectiveSense())
5454
MOI.set(model, MOI.ObjectiveSense(), MOI.FeasibilitySense)
5555
@test MOI.get(model, MOI.ObjectiveSense()) == MOI.FeasibilitySense
@@ -63,7 +63,7 @@ Test get objective function.
6363
"""
6464
function get_objective_function(model::MOI.ModelLike, config::TestConfig)
6565
MOI.empty!(model)
66-
@test MOI.isempty(model)
66+
@test MOI.is_empty(model)
6767
obj_attr = MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}()
6868
@test MOI.supports(model, obj_attr)
6969
MOIU.loadfromstring!(model,"""
@@ -94,7 +94,7 @@ correctly.
9494
function solve_constant_obj(model::MOI.ModelLike, config::TestConfig)
9595
atol, rtol = config.atol, config.rtol
9696
MOI.empty!(model)
97-
@test MOI.isempty(model)
97+
@test MOI.is_empty(model)
9898
MOIU.loadfromstring!(model,"""
9999
variables: x
100100
minobjective: 2.0x + 1.0
@@ -121,7 +121,7 @@ correctly.
121121
function solve_blank_obj(model::MOI.ModelLike, config::TestConfig)
122122
atol, rtol = config.atol, config.rtol
123123
MOI.empty!(model)
124-
@test MOI.isempty(model)
124+
@test MOI.is_empty(model)
125125
MOIU.loadfromstring!(model,"""
126126
variables: x
127127
minobjective: 0.0x + 0.0
@@ -148,7 +148,7 @@ correctly.
148148
function solve_singlevariable_obj(model::MOI.ModelLike, config::TestConfig)
149149
atol, rtol = config.atol, config.rtol
150150
MOI.empty!(model)
151-
@test MOI.isempty(model)
151+
@test MOI.is_empty(model)
152152
MOIU.loadfromstring!(model,"""
153153
variables: x
154154
minobjective: x
@@ -254,7 +254,7 @@ solves correctly.
254254
"""
255255
function solve_duplicate_terms_obj(model::MOI.ModelLike, config::TestConfig)
256256
MOI.empty!(model)
257-
@test MOI.isempty(model)
257+
@test MOI.is_empty(model)
258258
x = MOI.add_variable(model)
259259
c = MOI.add_constraint(model, MOI.SingleVariable(x), MOI.GreaterThan(1.0))
260260
MOI.set(model, MOI.ObjectiveSense(), MOI.MinSense)

src/Test/UnitTests/solve.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Test a variety of edge cases related to the ObjectiveBound attribute.
66
function solve_objbound_edge_cases(model::MOI.ModelLike, config::TestConfig)
77
@testset "Min IP with constant" begin
88
MOI.empty!(model)
9-
@test MOI.isempty(model)
9+
@test MOI.is_empty(model)
1010
MOIU.loadfromstring!(model, """
1111
variables: x
1212
minobjective: 2.0x + -1.0
@@ -25,7 +25,7 @@ function solve_objbound_edge_cases(model::MOI.ModelLike, config::TestConfig)
2525

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

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

6363
@testset "Max LP with constant" begin
6464
MOI.empty!(model)
65-
@test MOI.isempty(model)
65+
@test MOI.is_empty(model)
6666
MOIU.loadfromstring!(model, """
6767
variables: x
6868
maxobjective: 2.0x + 1.0

src/Test/UnitTests/variables.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Test adding a single variable.
2424
"""
2525
function add_variable(model::MOI.ModelLike, config::TestConfig)
2626
MOI.empty!(model)
27-
@test MOI.isempty(model)
27+
@test MOI.is_empty(model)
2828
@test MOI.get(model, MOI.NumberOfVariables()) == 0
2929
v = MOI.add_variable(model)
3030
@test MOI.get(model, MOI.NumberOfVariables()) == 1
@@ -38,7 +38,7 @@ Test adding multiple variables.
3838
"""
3939
function add_variables(model::MOI.ModelLike, config::TestConfig)
4040
MOI.empty!(model)
41-
@test MOI.isempty(model)
41+
@test MOI.is_empty(model)
4242
@test MOI.get(model, MOI.NumberOfVariables()) == 0
4343
v = MOI.add_variables(model, 2)
4444
@test MOI.get(model, MOI.NumberOfVariables()) == 2
@@ -52,7 +52,7 @@ Tess adding, and then deleting, a single variable.
5252
"""
5353
function delete_variable(model::MOI.ModelLike, config::TestConfig)
5454
MOI.empty!(model)
55-
@test MOI.isempty(model)
55+
@test MOI.is_empty(model)
5656
@test MOI.get(model, MOI.NumberOfVariables()) == 0
5757
v = MOI.add_variable(model)
5858
@test MOI.get(model, MOI.NumberOfVariables()) == 1
@@ -68,7 +68,7 @@ Test adding, and then deleting, multiple variables.
6868
"""
6969
function delete_variables(model::MOI.ModelLike, config::TestConfig)
7070
MOI.empty!(model)
71-
@test MOI.isempty(model)
71+
@test MOI.is_empty(model)
7272
@test MOI.get(model, MOI.NumberOfVariables()) == 0
7373
v = MOI.add_variables(model, 2)
7474
@test MOI.get(model, MOI.NumberOfVariables()) == 2
@@ -137,7 +137,7 @@ and if `config.duals=true`, check that the dual is computed correctly.
137137
function solve_with_upperbound(model::MOI.ModelLike, config::TestConfig)
138138
atol, rtol = config.atol, config.rtol
139139
MOI.empty!(model)
140-
@test MOI.isempty(model)
140+
@test MOI.is_empty(model)
141141
MOIU.loadfromstring!(model,"""
142142
variables: x
143143
maxobjective: 2.0x
@@ -165,7 +165,7 @@ and if `config.duals=true`, check that the dual is computed correctly.
165165
function solve_with_lowerbound(model::MOI.ModelLike, config::TestConfig)
166166
atol, rtol = config.atol, config.rtol
167167
MOI.empty!(model)
168-
@test MOI.isempty(model)
168+
@test MOI.is_empty(model)
169169
MOIU.loadfromstring!(model,"""
170170
variables: x
171171
minobjective: 2.0x
@@ -192,7 +192,7 @@ Test a variety of edge cases related to binary and integer variables.
192192
function solve_integer_edge_cases(model::MOI.ModelLike, config::TestConfig)
193193
@testset "integer with lower bound" begin
194194
MOI.empty!(model)
195-
@test MOI.isempty(model)
195+
@test MOI.is_empty(model)
196196
MOIU.loadfromstring!(model,"""
197197
variables: x
198198
minobjective: 2.0x
@@ -207,7 +207,7 @@ function solve_integer_edge_cases(model::MOI.ModelLike, config::TestConfig)
207207
end
208208
@testset "integer with upper bound" begin
209209
MOI.empty!(model)
210-
@test MOI.isempty(model)
210+
@test MOI.is_empty(model)
211211
MOIU.loadfromstring!(model,"""
212212
variables: x
213213
minobjective: -2.0x
@@ -223,7 +223,7 @@ function solve_integer_edge_cases(model::MOI.ModelLike, config::TestConfig)
223223

224224
@testset "binary with upper" begin
225225
MOI.empty!(model)
226-
@test MOI.isempty(model)
226+
@test MOI.is_empty(model)
227227
MOIU.loadfromstring!(model,"""
228228
variables: x
229229
minobjective: -2.0x
@@ -239,7 +239,7 @@ function solve_integer_edge_cases(model::MOI.ModelLike, config::TestConfig)
239239

240240
@testset "binary with 0 upper" begin
241241
MOI.empty!(model)
242-
@test MOI.isempty(model)
242+
@test MOI.is_empty(model)
243243
MOIU.loadfromstring!(model,"""
244244
variables: x
245245
minobjective: 1.0x

src/Test/contconic.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function _lin1test(model::MOI.ModelLike, config::TestConfig, vecofvars::Bool)
2121
@test MOI.supports_constraint(model, MOI.VectorAffineFunction{Float64}, MOI.Zeros)
2222

2323
MOI.empty!(model)
24-
@test MOI.isempty(model)
24+
@test MOI.is_empty(model)
2525

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

107107
MOI.empty!(model)
108-
@test MOI.isempty(model)
108+
@test MOI.is_empty(model)
109109

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

192192
MOI.empty!(model)
193-
@test MOI.isempty(model)
193+
@test MOI.is_empty(model)
194194

195195
x = MOI.add_variable(model)
196196

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

240240
MOI.empty!(model)
241-
@test MOI.isempty(model)
241+
@test MOI.is_empty(model)
242242

243243
x = MOI.add_variable(model)
244244

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

297297
MOI.empty!(model)
298-
@test MOI.isempty(model)
298+
@test MOI.is_empty(model)
299299

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

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

372372
MOI.empty!(model)
373-
@test MOI.isempty(model)
373+
@test MOI.is_empty(model)
374374

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

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

443443
MOI.empty!(model)
444-
@test MOI.isempty(model)
444+
@test MOI.is_empty(model)
445445

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

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

492492
MOI.empty!(model)
493-
@test MOI.isempty(model)
493+
@test MOI.is_empty(model)
494494

495495
x = MOI.add_variables(model, 5)
496496

@@ -561,7 +561,7 @@ function _rotatedsoc1test(model::MOI.ModelLike, config::TestConfig, abvars::Bool
561561
end
562562

563563
MOI.empty!(model)
564-
@test MOI.isempty(model)
564+
@test MOI.is_empty(model)
565565

566566
x = MOI.add_variables(model, 2)
567567
if abvars
@@ -650,7 +650,7 @@ function rotatedsoc2test(model::MOI.ModelLike, config::TestConfig)
650650
@test MOI.supports_constraint(model, MOI.VectorOfVariables,MOI.RotatedSecondOrderCone)
651651

652652
MOI.empty!(model)
653-
@test MOI.isempty(model)
653+
@test MOI.is_empty(model)
654654

655655
x = MOI.add_variables(model, 3)
656656

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

719719
MOI.empty!(model)
720-
@test MOI.isempty(model)
720+
@test MOI.is_empty(model)
721721

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

819819
MOI.empty!(model)
820-
@test MOI.isempty(model)
820+
@test MOI.is_empty(model)
821821

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

881881
MOI.empty!(model)
882-
@test MOI.isempty(model)
882+
@test MOI.is_empty(model)
883883

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

946946
MOI.empty!(model)
947-
@test MOI.isempty(model)
947+
@test MOI.is_empty(model)
948948

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

10111011
MOI.empty!(model)
1012-
@test MOI.isempty(model)
1012+
@test MOI.is_empty(model)
10131013

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

10811081
MOI.empty!(model)
1082-
@test MOI.isempty(model)
1082+
@test MOI.is_empty(model)
10831083

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

12151215
MOI.empty!(model)
1216-
@test MOI.isempty(model)
1216+
@test MOI.is_empty(model)
12171217

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

12951295
MOI.empty!(model)
1296-
@test MOI.isempty(model)
1296+
@test MOI.is_empty(model)
12971297

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

13971397
MOI.empty!(model)
1398-
@test MOI.isempty(model)
1398+
@test MOI.is_empty(model)
13991399

14001400
t = MOI.add_variable(model)
14011401
@test MOI.get(model, MOI.NumberOfVariables()) == 1

0 commit comments

Comments
 (0)