Skip to content

Commit

Permalink
Add many "see also" links to docstrings (#38606)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott authored Apr 19, 2021
1 parent b67d706 commit 2435f96
Show file tree
Hide file tree
Showing 50 changed files with 747 additions and 79 deletions.
82 changes: 70 additions & 12 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
Supertype for `N`-dimensional arrays (or array-like types) with elements of type `T`.
[`Array`](@ref) and other types are subtypes of this. See the manual section on the
[`AbstractArray` interface](@ref man-interface-array).
See also: [`AbstractVector`](@ref), [`AbstractMatrix`](@ref), [`eltype`](@ref), [`ndims`](@ref).
"""
AbstractArray

Expand All @@ -24,6 +26,8 @@ dimension to just get the length of that dimension.
Note that `size` may not be defined for arrays with non-standard indices, in which case [`axes`](@ref)
may be useful. See the manual chapter on [arrays with custom indices](@ref man-custom-indices).
See also: [`length`](@ref), [`ndims`](@ref), [`eachindex`](@ref), [`sizeof`](@ref).
# Examples
```jldoctest
julia> A = fill(1, (2,3,4));
Expand Down Expand Up @@ -75,6 +79,8 @@ end
Return the tuple of valid indices for array `A`.
See also: [`size`](@ref), [`keys`](@ref), [`eachindex`](@ref).
# Examples
```jldoctest
Expand Down Expand Up @@ -174,6 +180,8 @@ For dictionary types, this will be a `Pair{KeyType,ValType}`. The definition
instead of types. However the form that accepts a type argument should be defined for new
types.
See also: [`keytype`](@ref), [`typeof`](@ref).
# Examples
```jldoctest
julia> eltype(fill(1f0, (2,2)))
Expand Down Expand Up @@ -202,6 +210,8 @@ elsize(A::AbstractArray) = elsize(typeof(A))
Return the number of dimensions of `A`.
See also: [`size`](@ref), [`axes`](@ref).
# Examples
```jldoctest
julia> A = fill(1, (3,4,5));
Expand All @@ -220,6 +230,8 @@ Return the number of elements in the collection.
Use [`lastindex`](@ref) to get the last valid index of an indexable collection.
See also: [`size`](@ref), [`ndims`](@ref), [`eachindex`](@ref).
# Examples
```jldoctest
julia> length(1:5)
Expand Down Expand Up @@ -336,6 +348,8 @@ Return the last index of `collection`. If `d` is given, return the last index of
The syntaxes `A[end]` and `A[end, end]` lower to `A[lastindex(A)]` and
`A[lastindex(A, 1), lastindex(A, 2)]`, respectively.
See also: [`axes`](@ref), [`firstindex`](@ref), [`eachindex`](@ref), [`prevind`](@ref).
# Examples
```jldoctest
julia> lastindex([1,2,4])
Expand All @@ -354,6 +368,11 @@ lastindex(a, d) = (@_inline_meta; last(axes(a, d)))
Return the first index of `collection`. If `d` is given, return the first index of `collection` along dimension `d`.
The syntaxes `A[begin]` and `A[1, begin]` lower to `A[firstindex(A)]` and
`A[1, firstindex(A, 2)]`, respectively.
See also: [`first`](@ref), [`axes`](@ref), [`lastindex`](@ref), [`nextind`](@ref).
# Examples
```jldoctest
julia> firstindex([1,2,4])
Expand All @@ -374,6 +393,8 @@ first(a::AbstractArray) = a[first(eachindex(a))]
Get the first element of an iterable collection. Return the start point of an
[`AbstractRange`](@ref) even if it is empty.
See also: [`only`](@ref), [`firstindex`](@ref), [`last`](@ref).
# Examples
```jldoctest
julia> first(2:2:10)
Expand All @@ -395,6 +416,8 @@ end
Get the first `n` elements of the iterable collection `itr`, or fewer elements if `itr` is not
long enough.
See also: [`startswith`](@ref), [`Iterators.take`](@ref).
!!! compat "Julia 1.6"
This method requires at least Julia 1.6.
Expand Down Expand Up @@ -426,6 +449,8 @@ Get the last element of an ordered collection, if it can be computed in O(1) tim
accomplished by calling [`lastindex`](@ref) to get the last index. Return the end
point of an [`AbstractRange`](@ref) even if it is empty.
See also [`first`](@ref), [`endswith`](@ref).
# Examples
```jldoctest
julia> last(1:2:10)
Expand Down Expand Up @@ -472,6 +497,8 @@ end
Return a tuple of the memory strides in each dimension.
See also: [`stride`](@ref).
# Examples
```jldoctest
julia> A = fill(1, (3,4,5));
Expand All @@ -487,6 +514,8 @@ function strides end
Return the distance in memory (in number of elements) between adjacent elements in dimension `k`.
See also: [`strides`](@ref).
# Examples
```jldoctest
julia> A = fill(1, (3,4,5));
Expand Down Expand Up @@ -660,6 +689,8 @@ Return `true` if the given `index` is within the bounds of
arrays can extend this method in order to provide a specialized bounds
checking implementation.
See also [`checkbounds`](@ref).
# Examples
```jldoctest
julia> checkindex(Bool, 1:20, 8)
Expand Down Expand Up @@ -735,6 +766,7 @@ julia> similar(falses(10), Float64, 2, 4)
2.18425e-314 2.18425e-314 2.18425e-314 2.18425e-314
```
See also: [`undef`](@ref), [`isassigned`](@ref).
"""
similar(a::AbstractArray{T}) where {T} = similar(a, T)
similar(a::AbstractArray, ::Type{T}) where {T} = similar(a, T, to_shape(axes(a)))
Expand Down Expand Up @@ -791,6 +823,8 @@ similar(::Type{T}, dims::Dims) where {T<:AbstractArray} = T(undef, dims)
Create an empty vector similar to `v`, optionally changing the `eltype`.
See also: [`empty!`](@ref), [`isempty`](@ref), [`isassigned`](@ref).
# Examples
```jldoctest
Expand All @@ -815,6 +849,7 @@ elements in `dst`.
If `dst` and `src` are of the same type, `dst == src` should hold after
the call. If `dst` and `src` are multidimensional arrays, they must have
equal [`axes`](@ref).
See also [`copyto!`](@ref).
!!! compat "Julia 1.1"
Expand Down Expand Up @@ -922,11 +957,12 @@ end
"""
copyto!(dest::AbstractArray, src) -> dest
Copy all elements from collection `src` to array `dest`, whose length must be greater than
or equal to the length `n` of `src`. The first `n` elements of `dest` are overwritten,
the other elements are left untouched.
See also [`copy!`](@ref Base.copy!), [`copy`](@ref).
# Examples
```jldoctest
julia> x = [1., 0., 3., 0., 5.];
Expand Down Expand Up @@ -2130,18 +2166,28 @@ end
foreach(f, c...) -> Nothing
Call function `f` on each element of iterable `c`.
For multiple iterable arguments, `f` is called elementwise.
`foreach` should be used instead of `map` when the results of `f` are not
For multiple iterable arguments, `f` is called elementwise, and iteration stops when
any iterator is finished.
`foreach` should be used instead of [`map`](@ref) when the results of `f` are not
needed, for example in `foreach(println, array)`.
# Examples
```jldoctest
julia> a = 1:3:7;
julia> tri = 1:3:7; res = Int[];
julia> foreach(x -> println(x^2), a)
1
16
49
julia> foreach(x -> push!(res, x^2), tri)
julia> res
3-element Vector{$(Int)}:
1
16
49
julia> foreach((x, y) -> println(x, " with ", y), tri, 'a':'z')
1 with a
4 with b
7 with c
```
"""
foreach(f) = (f(); nothing)
Expand All @@ -2162,6 +2208,8 @@ colons go in this expression. The results are concatenated along the remaining d
For example, if `dims` is `[1,2]` and `A` is 4-dimensional, `f` is called on `A[:,:,i,j]`
for all `i` and `j`.
See also [`eachcol`](@ref), [`eachslice`](@ref).
# Examples
```jldoctest
julia> a = reshape(Vector(1:16),(2,2,2,2))
Expand Down Expand Up @@ -2308,9 +2356,9 @@ mapany(f, itr) = Any[f(x) for x in itr]
map(f, c...) -> collection
Transform collection `c` by applying `f` to each element. For multiple collection arguments,
apply `f` elementwise.
apply `f` elementwise, and stop when when any of them is exhausted.
See also: [`mapslices`](@ref)
See also: [`map!`](@ref), [`foreach`](@ref), [`mapreduce`](@ref), [`mapslices`](@ref), [`zip`](@ref), [`Iterators.map`](@ref).
# Examples
```jldoctest
Expand All @@ -2320,7 +2368,7 @@ julia> map(x -> x * 2, [1, 2, 3])
4
6
julia> map(+, [1, 2, 3], [10, 20, 30])
julia> map(+, [1, 2, 3], [10, 20, 30, 400, 5000])
3-element Vector{Int64}:
11
22
Expand Down Expand Up @@ -2365,7 +2413,9 @@ end
map!(function, destination, collection...)
Like [`map`](@ref), but stores the result in `destination` rather than a new
collection. `destination` must be at least as large as the first collection.
collection. `destination` must be at least as large as the smallest collection.
See also: [`map`](@ref), [`foreach`](@ref), [`zip`](@ref), [`copyto!`](@ref).
# Examples
```jldoctest
Expand All @@ -2378,6 +2428,14 @@ julia> a
2.0
4.0
6.0
julia> map!(+, zeros(Int, 5), 100:999, 1:3)
5-element Vector{$(Int)}:
101
103
105
0
0
```
"""
function map!(f::F, dest::AbstractArray, As::AbstractArray...) where {F}
Expand Down
16 changes: 11 additions & 5 deletions base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ julia> vec(1:3)
1:3
```
See also [`reshape`](@ref).
See also [`reshape`](@ref), [`dropdims`](@ref).
"""
vec(a::AbstractArray) = reshape(a,length(a))
vec(a::AbstractVector) = a
Expand All @@ -52,6 +52,8 @@ Remove the dimensions specified by `dims` from array `A`.
Elements of `dims` must be unique and within the range `1:ndims(A)`.
`size(A,i)` must equal 1 for all `i` in `dims`.
See also: [`reshape`](@ref), [`vec`](@ref).
# Examples
```jldoctest
julia> a = reshape(Vector(1:4),(2,2,1,1))
Expand Down Expand Up @@ -106,6 +108,8 @@ Return a view of all the data of `A` where the index for dimension `d` equals `i
Equivalent to `view(A,:,:,...,i,:,:,...)` where `i` is in position `d`.
See also: [`eachslice`](@ref).
# Examples
```jldoctest
julia> A = [1 2 3 4; 5 6 7 8]
Expand Down Expand Up @@ -143,6 +147,8 @@ Circularly shift, i.e. rotate, the data in an array. The second argument is a tu
vector giving the amount to shift in each dimension, or an integer to shift only in the
first dimension.
See also: [`circshift!`](@ref), [`circcopy!`](@ref), [`bitrotate`](@ref), [`<<`](@ref).
# Examples
```jldoctest
julia> b = reshape(Vector(1:16), (4,4))
Expand Down Expand Up @@ -190,8 +196,6 @@ julia> circshift(a, -1)
1
1
```
See also [`circshift!`](@ref).
"""
function circshift(a::AbstractArray, shiftamt)
circshift!(similar(a), a, map(Integer, (shiftamt...,)))
Expand All @@ -204,6 +208,8 @@ end
Construct an array by repeating array `A` a given number of times in each dimension, specified by `counts`.
See also: [`fill`](@ref), [`Iterators.repeated`](@ref), [`Iterators.cycle`](@ref).
# Examples
```jldoctest
julia> repeat([1, 2, 3], 2)
Expand Down Expand Up @@ -397,7 +403,7 @@ end#module
Create a generator that iterates over the first dimension of vector or matrix `A`,
returning the rows as `AbstractVector` views.
See also [`eachcol`](@ref) and [`eachslice`](@ref).
See also [`eachcol`](@ref), [`eachslice`](@ref), [`mapslices`](@ref).
!!! compat "Julia 1.1"
This function requires at least Julia 1.1.
Expand Down Expand Up @@ -465,7 +471,7 @@ the data from the other dimensions in `A`.
Only a single dimension in `dims` is currently supported. Equivalent to `(view(A,:,:,...,i,:,:
...)) for i in axes(A, dims))`, where `i` is in position `dims`.
See also [`eachrow`](@ref), [`eachcol`](@ref), and [`selectdim`](@ref).
See also [`eachrow`](@ref), [`eachcol`](@ref), [`mapslices`](@ref), and [`selectdim`](@ref).
!!! compat "Julia 1.1"
This function requires at least Julia 1.1.
Expand Down
14 changes: 13 additions & 1 deletion base/abstractset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ copy!(dst::AbstractSet, src::AbstractSet) = union!(empty!(dst), src)
Construct the union of sets. Maintain order with arrays.
See also: [`intersect`](@ref), [`isdisjoint`](@ref), [`vcat`](@ref), [`Iterators.flatten`](@ref).
# Examples
```jldoctest
julia> union([1, 2], [3, 4])
Expand Down Expand Up @@ -101,6 +103,8 @@ end
Construct the intersection of sets.
Maintain order with arrays.
See also: [`setdiff`](@ref), [`isdisjoint`](@ref), [`issubset`](@ref Base.issubset), [`issetequal`](@ref).
# Examples
```jldoctest
julia> intersect([1, 2, 3], [3, 4, 5])
Expand Down Expand Up @@ -145,6 +149,8 @@ intersect!(s::AbstractSet, itr) =
Construct the set of elements in `s` but not in any of the iterables in `itrs`.
Maintain order with arrays.
See also [`setdiff!`](@ref), [`union`](@ref) and [`intersect`](@ref).
# Examples
```jldoctest
julia> setdiff([1,2,3], [3,4,5])
Expand Down Expand Up @@ -194,6 +200,8 @@ Construct the symmetric difference of elements in the passed in sets.
When `s` is not an `AbstractSet`, the order is maintained.
Note that in this case the multiplicity of elements matters.
See also [`symdiff!`](@ref), [`setdiff`](@ref), [`union`](@ref) and [`intersect`](@ref).
# Examples
```jldoctest
julia> symdiff([1,2,3], [3,4,5], [4,5,6])
Expand Down Expand Up @@ -246,7 +254,7 @@ function ⊇ end
Determine whether every element of `a` is also in `b`, using [`in`](@ref).
See also [`⊊`](@ref), [`⊈`](@ref).
See also [`⊊`](@ref), [`⊈`](@ref), [`∩`](@ref intersect), [`∪`](@ref union), [`contains`](@ref).
# Examples
```jldoctest
Expand Down Expand Up @@ -357,6 +365,8 @@ false
Determine whether `a` and `b` have the same elements. Equivalent
to `a ⊆ b && b ⊆ a` but more efficient when possible.
See also: [`isdisjoint`](@ref), [`union`](@ref).
# Examples
```jldoctest
julia> issetequal([1, 2], [1, 2, 3])
Expand Down Expand Up @@ -390,6 +400,8 @@ end
Return whether the collections `v1` and `v2` are disjoint, i.e. whether
their intersection is empty.
See also: [`issetequal`](@ref), [`intersect`](@ref).
!!! compat "Julia 1.5"
This function requires at least Julia 1.5.
"""
Expand Down
Loading

2 comments on commit 2435f96

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your package evaluation job has completed - possible new issues were detected. A full report can be found here. cc @maleadt

Please sign in to comment.