Skip to content

Commit 05e0869

Browse files
authored
[docs] fix doc linking of DenseAxisArray and SparseAxisArray (#4013)
1 parent 0b1ac38 commit 05e0869

File tree

6 files changed

+58
-54
lines changed

6 files changed

+58
-54
lines changed

docs/src/manual/constraints.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,9 +1027,9 @@ julia> dual_start_value(con)
10271027

10281028
Like [Variable containers](@ref), JuMP provides a mechanism for building groups
10291029
of constraints compactly. References to these groups of constraints are returned
1030-
in *containers*. Three types of constraint containers are supported: `Array`s,
1031-
`DenseAxisArray`s, and `SparseAxisArray`s. We explain each of these in the
1032-
following.
1030+
in *containers*. Three types of constraint containers are supported: `Array`,
1031+
[`Containers.DenseAxisArray`](@ref), and [`Containers.SparseAxisArray`](@ref).
1032+
We explain each of these in the following.
10331033

10341034
!!! tip
10351035
You can read more about containers in the [Containers](@ref) section.
@@ -1075,14 +1075,14 @@ can determine at parse time that the indices are one-based integer ranges.
10751075
Therefore `con[1:b]` will create an `Array`, but `con[a:b]` will not. A special
10761076
case is `con[Base.OneTo(n)]` which will produce an `Array`. If JuMP cannot
10771077
determine that the indices are one-based integer ranges (for example, in the case of
1078-
`con[a:b]`), JuMP will create a `DenseAxisArray` instead.
1078+
`con[a:b]`), JuMP will create a [`Containers.DenseAxisArray`](@ref) instead.
10791079

10801080
### DenseAxisArrays
10811081

1082-
The syntax for constructing a [`DenseAxisArray`](@ref Containers.DenseAxisArray)
1082+
The syntax for constructing a [`Containers.DenseAxisArray`](@ref)
10831083
of constraints is very similar to the
1084-
[syntax for constructing](@ref variable_jump_arrays) a `DenseAxisArray` of
1085-
variables.
1084+
[syntax for constructing](@ref variable_jump_arrays) a [`Containers.DenseAxisArray`](@ref)
1085+
of variables.
10861086

10871087
```jldoctest constraint_jumparrays
10881088
julia> model = Model();
@@ -1100,10 +1100,9 @@ And data, a 2×2 Matrix{ConstraintRef{Model, MathOptInterface.ConstraintIndex{Ma
11001100

11011101
### SparseAxisArrays
11021102

1103-
The syntax for constructing a
1104-
[`SparseAxisArray`](@ref Containers.SparseAxisArray) of constraints is very
1105-
similar to the [syntax for constructing](@ref variable_sparseaxisarrays) a
1106-
`SparseAxisArray` of variables.
1103+
The syntax for constructing a [`Containers.SparseAxisArray`](@ref) of
1104+
constraints is very similar to the [syntax for constructing](@ref variable_sparseaxisarrays)
1105+
a [`Containers.SparseAxisArray`](@ref) of variables.
11071106

11081107
```jldoctest constraint_jumparrays
11091108
julia> model = Model();

docs/src/manual/containers.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ And data, a 2×2 Matrix{Tuple{Int64, Symbol}}:
155155

156156
### Slicing
157157

158-
DenseAxisArrays can be sliced
158+
A [`Containers.DenseAxisArray`](@ref) can be sliced:
159159
```jldoctest containers_dense
160160
julia> x[:, :A]
161161
1-dimensional DenseAxisArray{Tuple{Int64, Symbol},1,...} with index sets:
@@ -195,7 +195,7 @@ julia> axes(x)
195195

196196
### Broadcasting
197197

198-
Broadcasting over a DenseAxisArray returns a DenseAxisArray
198+
Broadcasting over a [`Containers.DenseAxisArray`](@ref) returns [`Containers.DenseAxisArray`](@ref):
199199
```jldoctest containers_dense
200200
julia> swap(x::Tuple) = (last(x), first(x))
201201
swap (generic function with 1 method)
@@ -229,8 +229,8 @@ julia> x.data
229229

230230
### Tables
231231

232-
Use [`Containers.rowtable`](@ref) to convert the `DenseAxisArray` into a
233-
[Tables.jl](https://github.com/JuliaData/Tables.jl) compatible
232+
Use [`Containers.rowtable`](@ref) to convert a [`Containers.DenseAxisArray`](@ref)
233+
into a [Tables.jl](https://github.com/JuliaData/Tables.jl) compatible
234234
`Vector{<:NamedTuple}`:
235235

236236
```jldoctest containers_dense
@@ -331,15 +331,17 @@ julia> for key in eachindex(y)
331331
```
332332

333333
!!! warning
334-
If you use a macro to construct a `SparseAxisArray`, then the iteration
335-
order is row-major, that is, indices are varied from right to left. As an
336-
example, when iterating over `x` above, the `j` index is iterated, keeping
337-
`i` constant. This order is in contrast to `Base.Array`s, which iterate in
338-
column-major order, that is, by varying indices from left to right.
334+
If you use a macro to construct a [`Containers.SparseAxisArray`](@ref), then
335+
the iteration order is row-major, that is, indices are varied from right to
336+
left. As an example, when iterating over `x` above, the `j` index is
337+
iterated, keeping `i` constant. This order is in contrast to `Base.Array`,
338+
which iterates in column-major order, that is, by varying indices from left
339+
to right.
339340

340341
### Broadcasting
341342

342-
Broadcasting over a SparseAxisArray returns a SparseAxisArray
343+
Broadcasting over a [`Containers.SparseAxisArray`](@ref) returns a
344+
[`Containers.SparseAxisArray`](@ref):
343345

344346
```jldoctest containers_sparse
345347
julia> swap(x::Tuple) = (last(x), first(x))
@@ -353,8 +355,8 @@ JuMP.Containers.SparseAxisArray{Tuple{Symbol, Int64}, 1, Tuple{Int64}} with 2 en
353355

354356
### Tables
355357

356-
Use [`Containers.rowtable`](@ref) to convert the `SparseAxisArray` into a
357-
[Tables.jl](https://github.com/JuliaData/Tables.jl) compatible
358+
Use [`Containers.rowtable`](@ref) to convert the [`Containers.SparseAxisArray`](@ref)
359+
into a [Tables.jl](https://github.com/JuliaData/Tables.jl) compatible
358360
`Vector{<:NamedTuple}`:
359361

360362
```jldoctest containers_sparse

docs/src/manual/variables.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,8 @@ x
800800
JuMP provides a mechanism for creating collections of variables in three types
801801
of data structures, which we refer to as *containers*.
802802

803-
The three types are `Array`s, `DenseAxisArray`s, and `SparseAxisArray`s. We
804-
explain each of these in the following.
803+
The three types are `Array`, [`Containers.DenseAxisArray`](@ref), and
804+
[`Containers.SparseAxisArray`](@ref). We explain each of these in the following.
805805

806806
!!! tip
807807
You can read more about containers in the [Containers](@ref) section.
@@ -850,7 +850,7 @@ JuMP will form an `Array` of JuMP variables when it can determine at compile
850850
time that the indices are one-based integer ranges. Therefore `x[1:b]` will
851851
create an `Array` of JuMP variables, but `x[a:b]` will not. If JuMP cannot
852852
determine that the indices are one-based integer ranges (for example, in the case of
853-
`x[a:b]`), JuMP will create a `DenseAxisArray` instead.
853+
`x[a:b]`), JuMP will create a [`Containers.DenseAxisArray`](@ref) instead.
854854

855855
### [DenseAxisArrays](@id variable_jump_arrays)
856856

@@ -859,7 +859,7 @@ ranges. For example, we may want to create a variable indexed by the name of a
859859
product or a location. The syntax is the same as that above, except with an
860860
arbitrary vector as an index as opposed to a one-based range. The biggest
861861
difference is that instead of returning an `Array` of JuMP variables, JuMP will
862-
return a `DenseAxisArray`. For example:
862+
return a [`Containers.DenseAxisArray`](@ref). For example:
863863
```jldoctest variables_jump_arrays
864864
julia> model = Model();
865865
@@ -872,7 +872,7 @@ And data, a 2×2 Matrix{VariableRef}:
872872
x[2,A] x[2,B]
873873
```
874874

875-
DenseAxisArrays can be indexed and sliced as follows:
875+
A [`Containers.DenseAxisArray`](@ref) can be indexed and sliced as follows:
876876
```jldoctest variables_jump_arrays
877877
julia> x[1, :A]
878878
x[1,A]
@@ -908,7 +908,7 @@ And data, a 2×2 Matrix{Float64}:
908908

909909
### [SparseAxisArrays](@id variable_sparseaxisarrays)
910910

911-
The third container type that JuMP natively supports is `SparseAxisArray`.
911+
The third container type that JuMP natively supports is [`Containers.SparseAxisArray`](@ref).
912912
These arrays are created when the indices do not form a rectangular set.
913913
For example, this applies when indices have a dependence upon previous
914914
indices (called *triangular indexing*). JuMP supports this as follows:
@@ -996,9 +996,10 @@ using the filtering syntax.
996996

997997
When creating a container of JuMP variables, JuMP will attempt to choose the
998998
tightest container type that can store the JuMP variables. Thus, it will prefer
999-
to create an Array before a DenseAxisArray and a DenseAxisArray before a
1000-
SparseAxisArray. However, because this happens at compile time, JuMP does not
1001-
always make the best choice. To illustrate this, consider the following example:
999+
to create an `Array` before a [`Containers.DenseAxisArray`](@ref) and a
1000+
[`Containers.DenseAxisArray`](@ref) before a [`Containers.SparseAxisArray`](@ref).
1001+
However, because this happens at compile time, JuMP does not always make the
1002+
best choice. To illustrate this, consider the following example:
10021003
```jldoctest variable_force_container
10031004
julia> model = Model();
10041005
@@ -1014,8 +1015,8 @@ And data, a 2-element Vector{VariableRef}:
10141015
```
10151016
Since the value (and type) of `A` is unknown at parsing time, JuMP is unable to
10161017
infer that `A` is a one-based integer range. Therefore, JuMP creates a
1017-
`DenseAxisArray`, even though it could store these two variables in a standard
1018-
one-dimensional `Array`.
1018+
[`Containers.DenseAxisArray`](@ref), even though it could store these two
1019+
variables in a standard one-dimensional `Array`.
10191020

10201021
We can share our knowledge that it is possible to store these JuMP variables as
10211022
an array by setting the `container` keyword:
@@ -1025,7 +1026,7 @@ julia> @variable(model, y[A], container=Array)
10251026
y[1]
10261027
y[2]
10271028
```
1028-
JuMP now creates a vector of JuMP variables instead of a DenseAxisArray.
1029+
JuMP now creates a `Vector` of JuMP variables instead of a [`Containers.DenseAxisArray](@ref).
10291030
Choosing an invalid container type will throw an error.
10301031

10311032
### User-defined containers
@@ -1119,7 +1120,7 @@ nonnegative.
11191120

11201121
!!! note
11211122
`x` must be a square 2-dimensional `Array` of JuMP variables; it cannot be a
1122-
DenseAxisArray or a SparseAxisArray.
1123+
[`Containers.DenseAxisArray`](@ref) or a [`Containers.SparseAxisArray`](@ref).
11231124

11241125
Use [`VariableInSetRef`](@ref) to obtain the associated constraint reference:
11251126

docs/src/tutorials/getting_started/design_patterns_for_larger_models.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,9 @@ Solve the knapsack problem and return the optimal primal solution
612612
613613
## Returns
614614
615-
* If an optimal solution exists: a `JuMP.DenseAxisArray` that maps the `String`
616-
name of each object to the number of objects to pack into the knapsack.
615+
* If an optimal solution exists: a `JuMP.Containers.DenseAxisArray` that maps
616+
the `String` name of each object to the number of objects to pack into the
617+
knapsack.
617618
* Otherwise, `nothing`, indicating that the problem does not have an optimal
618619
solution.
619620

docs/src/tutorials/getting_started/getting_started_with_JuMP.jl

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ end #hide
336336

337337
# JuMP provides data structures for adding collections of variables to a model.
338338
# These data structures are referred to as _containers_ and are of three types:
339-
# `Arrays`, `DenseAxisArrays`, and `SparseAxisArrays`.
339+
# `Array`, [`Containers.DenseAxisArray`](@ref), and [`Containers.SparseAxisArray`](@ref).
340340

341341
# #### Arrays
342342

@@ -367,17 +367,17 @@ u = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19];
367367

368368
# #### DenseAxisArrays
369369

370-
# `DenseAxisArrays` are used when the indices are not one-based integer ranges.
371-
# The syntax is similar except with an arbitrary vector as an index as opposed
372-
# to a one-based range:
370+
# [`Containers.DenseAxisArray`](@ref) is used when the indices are not one-based
371+
# integer ranges. The syntax is similar, except with an arbitrary vector as an
372+
# index as opposed to a one-based range:
373373

374374
@variable(model, z[i = 2:3, j = 1:2:3] >= 0)
375375

376376
# Indices do not have to be integers. They can be any Julia type:
377377

378378
@variable(model, w[1:5, ["red", "blue"]] <= 1)
379379

380-
# Index elements in a `DenseAxisArray` as follows:
380+
# Index elements in a [`Containers.DenseAxisArray`](@ref) as follows:
381381

382382
z[2, 1]
383383

@@ -389,9 +389,9 @@ w[2:3, ["red", "blue"]]
389389

390390
# #### SparseAxisArrays
391391

392-
# `SparseAxisArrays` are created when the indices do not form a Cartesian product.
393-
# For example, this applies when indices have a dependence upon previous indices
394-
# (called triangular indexing):
392+
# A [`Containers.SparseAxisArray`](@ref) is created when the indices do not form
393+
# a Cartesian product. For example, this applies when indices have a dependence
394+
# upon previous indices (called triangular indexing):
395395

396396
@variable(model, u[i = 1:2, j = i:3])
397397

@@ -401,7 +401,7 @@ w[2:3, ["red", "blue"]]
401401

402402
@variable(model, v[i = 1:9; mod(i, 3) == 0])
403403

404-
# Index elements in a `DenseAxisArray` as follows:
404+
# Index elements in a [`Containers.SparseAxisArray`](@ref) as follows:
405405

406406
u[1, 2]
407407

@@ -446,9 +446,10 @@ model = Model()
446446

447447
# ### [Containers](@id tutorial_constraint_container)
448448

449-
# Just as we had containers for variables, JuMP also provides `Arrays`,
450-
# `DenseAxisArrays`, and `SparseAxisArrays` for storing collections of
451-
# constraints. Examples for each container type are given below.
449+
# Just as we had containers for variables, JuMP also provides `Array`,
450+
# [`Containers.DenseAxisArray`](@ref), and [`Containers.SparseAxisArray`](@ref)
451+
# for storing collections of constraints. Examples for each container type are
452+
# given below.
452453

453454
# #### Arrays
454455

@@ -458,13 +459,13 @@ model = Model()
458459

459460
# #### DenseAxisArrays
460461

461-
# Create an `DenseAxisArray` of constraints:
462+
# Create a [`Containers.DenseAxisArray`](@ref) of constraints:
462463

463464
@constraint(model, [i = 1:2, j = 2:3], i * x <= j + 1)
464465

465466
# #### SparseAxisArrays
466467

467-
# Create an `SparseAxisArray` of constraints:
468+
# Create a [`Containers.SparseAxisArray`](@ref) of constraints:
468469

469470
@constraint(model, [i = 1:2, j = 1:2; i != j], i * x <= j + 1)
470471

docs/src/tutorials/linear/diet.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ set_silent(model)
118118
@variable(model, x[foods.name] >= 0)
119119

120120
# To simplify things later on, we store the vector as a new column `x` in the
121-
# DataFrame `foods`. Since `x` is a `DenseAxisArray`, we first need to convert
122-
# it to an `Array`:
121+
# DataFrame `foods`. Since `x` is a [`Containers.DenseAxisArray`](@ref), we
122+
# first need to convert it to an `Array`:
123123

124124
foods.x = Array(x)
125125

0 commit comments

Comments
 (0)