Skip to content

Commit 7543afe

Browse files
Doctests modified to work with both 1.5.2 and 1.0.5 + comments on what to do when 1.6 is the new LTS. Closes #990 (#1184)
1 parent 0b93034 commit 7543afe

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

docs/src/apireference.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ CurrentModule = MathOptInterface
33
DocTestSetup = quote
44
using MathOptInterface
55
const MOI = MathOptInterface
6+
7+
# For compatibility with both Julia 1.0.5 and 1.5.2
8+
# Upon the Julia LTS version becoming 1.6, these imports could be dropped,
9+
# and all ScalarAffineTerm and VariableIndex instances in doctests below
10+
# could be replaced with MOI.ScalarAffineTerm and MOI.VariableIndex
11+
# Check discussion at PR 1184: https://github.com/jump-dev/MathOptInterface.jl/pull/1184#discussion_r515300914
12+
import MathOptInterface.ScalarAffineTerm
13+
import MathOptInterface.VariableIndex
614
end
715
DocTestFilters = [r"MathOptInterface|MOI"]
816
```
@@ -625,7 +633,7 @@ bridged_variable, bridged_constraint = MOI.add_constrained_variable(bridged_mode
625633
626634
# output
627635
628-
(MOI.VariableIndex(-1), MOI.ConstraintIndex{MOI.SingleVariable,MOI.GreaterThan{Float64}}(-1))
636+
(VariableIndex(-1), MOI.ConstraintIndex{MOI.SingleVariable,MOI.GreaterThan{Float64}}(-1))
629637
```
630638
The constrained variable in `MOI.GreaterThan(1.0)` returned is a bridged
631639
variable as its index in negative. In `model`, a constrained variable in
@@ -635,8 +643,8 @@ inner_variables = MOI.get(model, MOI.ListOfVariableIndices())
635643
636644
# output
637645
638-
1-element Array{MOI.VariableIndex,1}:
639-
MOI.VariableIndex(1)
646+
1-element Array{VariableIndex,1}:
647+
VariableIndex(1)
640648
```
641649
In the functions used for adding constraints or setting the objective to
642650
`bridged_model`, `bridged_variable` is substituted for `inner_variables[1]` plus

0 commit comments

Comments
 (0)