Skip to content

Commit 6e61a86

Browse files
authored
Add import MathOptInterface as MOI to DocTestSetup (#2746)
1 parent 7f02104 commit 6e61a86

30 files changed

+24
-297
lines changed

docs/make.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ end
123123
# link checking. Inn production we replace this by running the LaTeX build.
124124
write(joinpath(@__DIR__, "src", "MathOptInterface.pdf"), "")
125125

126+
Documenter.DocMeta.setdocmeta!(
127+
MathOptInterface,
128+
:DocTestSetup,
129+
:(import MathOptInterface as MOI);
130+
recursive = true,
131+
)
132+
126133
@time Documenter.makedocs(
127134
sitename = "MathOptInterface",
128135
authors = "The JuMP core developers and contributors",

src/Benchmarks/Benchmarks.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ Extra `kwargs` are based to `BenchmarkTools.run`.
5353
## Example
5454
5555
```julia
56-
julia> import MathOptInterface as MOI
57-
5856
julia> import GLPK
5957
6058
julia> my_suite = MOI.Benchmarks.suite(() -> GLPK.Optimizer());
@@ -100,8 +98,6 @@ Extra `kwargs` are based to `BenchmarkTools.run`.
10098
## Example
10199
102100
```julia
103-
julia> import MathOptInterface as MOI
104-
105101
julia> import GLPK
106102
107103
julia> my_suite = MOI.Benchmarks.suite(() -> GLPK.Optimizer());

src/Bridges/Bridges.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ coefficient type `T`, as well as the bridges in the list returned by the
4141
4242
## Example
4343
44-
```jldoctest; setup=:(import MathOptInterface as MOI)
44+
```jldoctest
4545
julia> model = MOI.Utilities.Model{Float64}();
4646
4747
julia> bridged_model = MOI.Bridges.full_bridge_optimizer(model, Float64);
@@ -273,7 +273,7 @@ and [`MOI.ConstraintPrimalStart`](@ref) to throw [`MOI.GetAttributeNotAllowed`](
273273
274274
## Example
275275
276-
```jldoctest; setup=:(import MathOptInterface as MOI), filter=r"[0-9.]+s"
276+
```jldoctest; filter=r"[0-9.]+s"
277277
julia> MOI.Bridges.runtests(
278278
MOI.Bridges.Constraint.ZeroOneBridge,
279279
model -> MOI.add_constrained_variable(model, MOI.ZeroOne()),
@@ -423,7 +423,7 @@ Run a series of tests that check the correctness of `Bridge`.
423423
424424
## Example
425425
426-
```jldoctest; setup=:(import MathOptInterface as MOI), filter=r"[0-9.]+s"
426+
```jldoctest; filter=r"[0-9.]+s"
427427
julia> MOI.Bridges.runtests(
428428
MOI.Bridges.Constraint.ZeroOneBridge,
429429
\"\"\"

src/Bridges/Constraint/bridge.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The [`SplitIntervalBridge`](@ref) bridges a [`MOI.VariableIndex`](@ref)-in-[`MOI
6161
constraint into a [`MOI.VariableIndex`](@ref)-in-[`MOI.GreaterThan`](@ref) and a
6262
[`MOI.VariableIndex`](@ref)-in-[`MOI.LessThan`](@ref) constraint.
6363
64-
```jldoctest; setup=:(import MathOptInterface as MOI)
64+
```jldoctest
6565
julia> MOI.Bridges.Constraint.concrete_bridge_type(
6666
MOI.Bridges.Constraint.SplitIntervalBridge{Float64},
6767
MOI.VariableIndex,

src/Bridges/Constraint/single_bridge_optimizer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ and unsupported by `model`.
1616
1717
## Example
1818
19-
```jldoctest con_singlebridgeoptimizer; setup=:(import MathOptInterface as MOI)
19+
```jldoctest con_singlebridgeoptimizer
2020
julia> struct MyNewBridge{T} <: MOI.Bridges.Constraint.AbstractBridge end
2121
2222
julia> bridge = MOI.Bridges.Constraint.SingleBridgeOptimizer{MyNewBridge{Float64}}(

src/Bridges/Objective/single_bridge_optimizer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ and unsupported by `model`.
1616
1717
## Example
1818
19-
```jldoctest obj_singlebridgeoptimizer; setup=:(import MathOptInterface as MOI)
19+
```jldoctest obj_singlebridgeoptimizer
2020
julia> struct MyNewBridge{T} <: MOI.Bridges.Objective.AbstractBridge end
2121
2222
julia> bridge = MOI.Bridges.Objective.SingleBridgeOptimizer{MyNewBridge{Float64}}(

src/Bridges/Variable/bridge.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ solver.
3939
4040
## Example
4141
42-
```jldoctest; setup=(import MathOptInterface as MOI)
42+
```jldoctest
4343
julia> MOI.Bridges.Variable.supports_constrained_variable(
4444
MOI.Bridges.Variable.NonposToNonnegBridge{Float64},
4545
MOI.Nonpositives,
@@ -78,8 +78,6 @@ variables in [`MOI.Nonnegatives`](@ref) by the
7878
[`VectorizeBridge`](@ref):
7979
8080
```jldoctest
81-
julia> import MathOptInterface as MOI
82-
8381
julia> MOI.Bridges.Variable.concrete_bridge_type(
8482
MOI.Bridges.Variable.VectorizeBridge{Float64},
8583
MOI.GreaterThan{Float64},

src/Bridges/Variable/single_bridge_optimizer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ by the bridge `BT` and unsupported by `model`.
2121
2222
## Example
2323
24-
```jldoctest var_singlebridgeoptimizer; setup=:(import MathOptInterface as MOI)
24+
```jldoctest var_singlebridgeoptimizer
2525
julia> struct MyNewBridge{T} <: MOI.Bridges.Variable.AbstractBridge end
2626
2727
julia> bridge = MOI.Bridges.Variable.SingleBridgeOptimizer{MyNewBridge{Float64}}(

src/Bridges/bridge.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ type `BT` add.
203203
204204
## Example
205205
206-
```jldoctest; setup=(import MathOptInterface as MOI)
206+
```jldoctest
207207
julia> MOI.Bridges.added_constrained_variable_types(
208208
MOI.Bridges.Variable.NonposToNonnegBridge{Float64},
209209
)
@@ -229,7 +229,7 @@ add.
229229
230230
## Example
231231
232-
```jldoctest; setup=(import MathOptInterface as MOI)
232+
```jldoctest
233233
julia> MOI.Bridges.added_constraint_types(
234234
MOI.Bridges.Constraint.ZeroOneBridge{Float64},
235235
)
@@ -254,7 +254,7 @@ set.
254254
255255
## Example
256256
257-
```jldoctest; setup=(import MathOptInterface as MOI)
257+
```jldoctest
258258
julia> MOI.Bridges.set_objective_function_type(
259259
MOI.Bridges.Objective.FunctionizeBridge{Float64},
260260
)
@@ -311,7 +311,7 @@ constraint.
311311
For this reason, the [`Bridges.Constraint.FunctionConversionBridge`](@ref) is
312312
given a cost of `10`:
313313
314-
```jldoctest; setup=(import MathOptInterface as MOI)
314+
```jldoctest
315315
julia> F = MOI.ScalarQuadraticFunction{Float64};
316316
317317
julia> G = MOI.ScalarAffineFunction{Float64};

src/Bridges/lazy_bridge_optimizer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ and [`full_bridge_optimizer`](@ref).
2424
2525
## Example
2626
27-
```jldoctest; setup=:(import MathOptInterface as MOI)
27+
```jldoctest
2828
julia> model = MOI.Bridges.LazyBridgeOptimizer(MOI.Utilities.Model{Float64}());
2929
3030
julia> MOI.Bridges.add_bridge(model, MOI.Bridges.Variable.FreeBridge{Float64})

src/Nonlinear/ReverseAD/utils.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,6 @@ end.
182182
## Examples
183183
184184
```jldoctest
185-
julia> import MathOptInterface as MOI
186-
187185
julia> x = [(1, 2, 3), (4, 5, 6), (7, 8, 9)]
188186
3-element Vector{Tuple{Int64, Int64, Int64}}:
189187
(1, 2, 3)

src/Nonlinear/SymbolicAD/SymbolicAD.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ Return a simplified copy of the function `f`.
2222
## Example
2323
2424
```jldoctest
25-
julia> import MathOptInterface as MOI
26-
2725
julia> x = MOI.VariableIndex(1)
2826
MOI.VariableIndex(1)
2927
@@ -52,8 +50,6 @@ new object if `f` can be represented in a simpler type.
5250
## Example
5351
5452
```jldoctest
55-
julia> import MathOptInterface as MOI
56-
5753
julia> x = MOI.VariableIndex(1)
5854
MOI.VariableIndex(1)
5955
@@ -356,8 +352,6 @@ Return a sorted list of the `MOI.VariableIndex` present in the function `f`.
356352
## Example
357353
358354
```jldoctest
359-
julia> import MathOptInterface as MOI
360-
361355
julia> x = MOI.VariableIndex.(1:3)
362356
3-element Vector{MathOptInterface.VariableIndex}:
363357
MOI.VariableIndex(1)
@@ -463,8 +457,6 @@ simplified expression of the derivative.
463457
## Example
464458
465459
```jldoctest
466-
julia> import MathOptInterface as MOI
467-
468460
julia> x = MOI.VariableIndex(1)
469461
MOI.VariableIndex(1)
470462

src/Nonlinear/evaluator.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ Return the 1-indexed value of the constraint index `c` in `evaluator`.
1616
## Example
1717
1818
```jldoctest
19-
julia> import MathOptInterface as MOI
20-
2119
julia> model = MOI.Nonlinear.Model()
2220
A Nonlinear.Model with:
2321
0 objectives

src/Nonlinear/model.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ To remove the objective, pass `nothing`.
5050
## Example
5151
5252
```jldoctest
53-
julia> import MathOptInterface as MOI
54-
5553
julia> model = MOI.Nonlinear.Model()
5654
A Nonlinear.Model with:
5755
0 objectives
@@ -90,8 +88,6 @@ Parse `expr` into a [`Expression`](@ref) and add to `model`. Returns an
9088
## Example
9189
9290
```jldoctest
93-
julia> import MathOptInterface as MOI
94-
9591
julia> model = MOI.Nonlinear.Model();
9692
9793
julia> x = MOI.VariableIndex(1);
@@ -130,8 +126,6 @@ solution information.
130126
## Example
131127
132128
```jldoctest
133-
julia> import MathOptInterface as MOI
134-
135129
julia> model = MOI.Nonlinear.Model();
136130
137131
julia> x = MOI.VariableIndex(1);
@@ -165,8 +159,6 @@ Delete the constraint index `c` from `model`.
165159
## Example
166160
167161
```jldoctest
168-
julia> import MathOptInterface as MOI
169-
170162
julia> model = MOI.Nonlinear.Model()
171163
A Nonlinear.Model with:
172164
0 objectives
@@ -220,8 +212,6 @@ and used to modify the value of the parameter.
220212
## Example
221213
222214
```jldoctest
223-
julia> import MathOptInterface as MOI
224-
225215
julia> model = MOI.Nonlinear.Model()
226216
A Nonlinear.Model with:
227217
0 objectives

src/Nonlinear/operators.jl

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ The list of univariate operators that are supported by default.
105105
## Example
106106
107107
```jldoctest
108-
julia> import MathOptInterface as MOI
109-
110108
julia> MOI.Nonlinear.DEFAULT_UNIVARIATE_OPERATORS
111109
73-element Vector{Symbol}:
112110
:+
@@ -141,8 +139,6 @@ The list of multivariate operators that are supported by default.
141139
## Example
142140
143141
```jldoctest
144-
julia> import MathOptInterface as MOI
145-
146142
julia> MOI.Nonlinear.DEFAULT_MULTIVARIATE_OPERATORS
147143
9-element Vector{Symbol}:
148144
:+
@@ -550,8 +546,6 @@ If `op isa Integer`, then `op` is the index in
550546
## Example
551547
552548
```jldoctest
553-
julia> import MathOptInterface as MOI
554-
555549
julia> r = MOI.Nonlinear.OperatorRegistry();
556550
557551
julia> MOI.Nonlinear.eval_univariate_function(r, :abs, -1.2)
@@ -603,8 +597,6 @@ If `op isa Integer`, then `op` is the index in
603597
## Example
604598
605599
```jldoctest
606-
julia> import MathOptInterface as MOI
607-
608600
julia> r = MOI.Nonlinear.OperatorRegistry();
609601
610602
julia> MOI.Nonlinear.eval_univariate_gradient(r, :abs, -1.2)
@@ -656,8 +648,6 @@ If `op isa Integer`, then `op` is the index in
656648
## Example
657649
658650
```jldoctest
659-
julia> import MathOptInterface as MOI
660-
661651
julia> r = MOI.Nonlinear.OperatorRegistry();
662652
663653
julia> MOI.Nonlinear.eval_univariate_function_and_gradient(r, :abs, -1.2)
@@ -708,8 +698,6 @@ If `op isa Integer`, then `op` is the index in
708698
## Example
709699
710700
```jldoctest
711-
julia> import MathOptInterface as MOI
712-
713701
julia> r = MOI.Nonlinear.OperatorRegistry();
714702
715703
julia> MOI.Nonlinear.eval_univariate_hessian(r, :sin, 1.0)

src/Test/Test.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ For a nonlinear solver that finds local optima and does not support finding
7878
dual variables or constraint names:
7979
8080
```jldoctest
81-
julia> import MathOptInterface as MOI
82-
8381
julia> config = MOI.Test.Config(
8482
Float64;
8583
optimal_status = MOI.LOCALLY_SOLVED,

src/Utilities/functions.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,8 +1034,6 @@ The output of `canonical` can be assumed to be a copy of `f`, even for
10341034
## Example
10351035
10361036
```jldoctest
1037-
julia> import MathOptInterface as MOI
1038-
10391037
julia> x, y, z = MOI.VariableIndex.(1:3);
10401038
10411039
julia> f = MOI.ScalarAffineFunction(
@@ -1165,8 +1163,6 @@ want to first call [`canonical`](@ref) if that is not guaranteed.
11651163
## Example
11661164
11671165
```jldoctest
1168-
julia> import MathOptInterface as MOI
1169-
11701166
julia> x = MOI.VariableIndex(1)
11711167
MOI.VariableIndex(1)
11721168
@@ -2557,8 +2553,6 @@ complex-valued).
25572553
## Example
25582554
25592555
```jldoctest
2560-
julia> import MathOptInterface as MOI
2561-
25622556
julia> MOI.Utilities.is_complex(MOI.VariableIndex)
25632557
false
25642558

src/Utilities/model.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,8 +859,6 @@ in MOI. It is parameterized by the coefficient type.
859859
## Example
860860
861861
```jldoctest
862-
julia> import MathOptInterface as MOI
863-
864862
julia> model = MOI.Utilities.Model{Float64}()
865863
MOIU.Model{Float64}
866864
├ ObjectiveSense: FEASIBILITY_SENSE

src/Utilities/parser.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ A utility function to aid writing tests.
337337
338338
## Example
339339
340-
```jldoctest; setup=:(import MathOptInterface as MOI)
340+
```jldoctest
341341
julia> model = MOI.Utilities.Model{Float64}();
342342
343343
julia> MOI.Utilities.loadfromstring!(model, \"\"\"

src/Utilities/penalty_relaxation.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ this function to compute the violation of the constraint.
3434
3535
## Example
3636
37-
```jldoctest; setup=:(import MathOptInterface as MOI)
37+
```jldoctest
3838
julia> model = MOI.Utilities.Model{Float64}();
3939
4040
julia> x = MOI.add_variable(model);
@@ -189,7 +189,7 @@ To modify variable bounds, rewrite them as linear constraints.
189189
190190
## Example
191191
192-
```jldoctest; setup=:(import MathOptInterface as MOI)
192+
```jldoctest
193193
julia> model = MOI.Utilities.Model{Float64}();
194194
195195
julia> x = MOI.add_variable(model);
@@ -214,7 +214,7 @@ julia> map[c] isa MOI.ScalarAffineFunction{Float64}
214214
true
215215
```
216216
217-
```jldoctest; setup=:(import MathOptInterface as MOI)
217+
```jldoctest
218218
julia> model = MOI.Utilities.Model{Float64}();
219219
220220
julia> x = MOI.add_variable(model);

0 commit comments

Comments
 (0)