From cb81ceb28c66716ba0c3a9850b170b057c7d9eb8 Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Sun, 29 Nov 2020 16:19:32 +0100 Subject: [PATCH 01/28] see also... many things --- base/abstractarray.jl | 20 +++++++++++++++++++- base/abstractarraymath.jl | 6 +++--- base/abstractset.jl | 14 ++++++++++++++ base/accumulate.jl | 2 ++ base/array.jl | 11 ++++++++++- base/combinatorics.jl | 2 ++ base/docs/basedocs.jl | 8 +++++++- base/float.jl | 14 ++++++++++++-- base/int.jl | 2 ++ base/multidimensional.jl | 2 ++ base/number.jl | 9 +++++++++ base/permuteddimsarray.jl | 4 ++-- base/reducedim.jl | 2 ++ base/reflection.jl | 4 +++- base/show.jl | 4 +++- base/sort.jl | 2 +- stdlib/LinearAlgebra/src/dense.jl | 7 +++++-- stdlib/LinearAlgebra/src/generic.jl | 2 ++ 18 files changed, 100 insertions(+), 15 deletions(-) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index bb697ca11bc14..27d3226f3a623 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -373,6 +373,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) @@ -422,6 +424,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). + # Examples ```jldoctest julia> last(1:2:10) @@ -465,6 +469,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)); @@ -480,6 +486,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)); @@ -653,6 +661,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) @@ -728,6 +738,7 @@ julia> similar(falses(10), Float64, 2, 4) 2.18425e-314 2.18425e-314 2.18425e-314 2.18425e-314 ``` +See also: [`undef`](@ref). """ similar(a::AbstractArray{T}) where {T} = similar(a, T) similar(a::AbstractArray, ::Type{T}) where {T} = similar(a, T, to_shape(axes(a))) @@ -783,6 +794,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). + # Examples ```jldoctest @@ -807,6 +820,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" @@ -919,6 +933,8 @@ Copy all elements from collection `src` to array `dest`, whose length must be gr 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), [`copy`](@ref). + # Examples ```jldoctest julia> x = [1., 0., 3., 0., 5.]; @@ -2143,6 +2159,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)) @@ -2291,7 +2309,7 @@ mapany(f, itr) = Any[f(x) for x in itr] Transform collection `c` by applying `f` to each element. For multiple collection arguments, apply `f` elementwise. -See also: [`mapslices`](@ref) +See also: [`map!`](@ref), [`foreach`](@ref), [`mapreduce`](@ref), [`mapslices`](@ref). # Examples ```jldoctest diff --git a/base/abstractarraymath.jl b/base/abstractarraymath.jl index 953c190ab12ef..cad1b3f67ef74 100644 --- a/base/abstractarraymath.jl +++ b/base/abstractarraymath.jl @@ -138,6 +138,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). + # Examples ```jldoctest julia> b = reshape(Vector(1:16), (4,4)) @@ -185,8 +187,6 @@ julia> circshift(a, -1) 1 1 ``` - -See also [`circshift!`](@ref). """ function circshift(a::AbstractArray, shiftamt) circshift!(similar(a), a, map(Integer, (shiftamt...,))) @@ -460,7 +460,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. diff --git a/base/abstractset.jl b/base/abstractset.jl index 179b9f7be5d4b..86b54d16fe6d0 100644 --- a/base/abstractset.jl +++ b/base/abstractset.jl @@ -13,6 +13,8 @@ copy!(dst::AbstractSet, src::AbstractSet) = union!(empty!(dst), src) Construct the union of sets. Maintain order with arrays. +See also: [`vcat`](@ref), [`intersect`](@ref), [`isdisjoint`](@ref). + # Examples ```jldoctest julia> union([1, 2], [3, 4]) @@ -101,6 +103,8 @@ end Construct the intersection of sets. Maintain order with arrays. +See also: [`setdiff`](@ref), [`isdisjoint`](@ref), [`issubset`](@ref), [`issetequal`](@ref). + # Examples ```jldoctest julia> intersect([1, 2, 3], [3, 4, 5]) @@ -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]) @@ -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]) @@ -246,6 +254,8 @@ function ⊇ end Determine whether every element of `a` is also in `b`, using [`in`](@ref). +See also [`⊈`](@ref) and [`⊉`](@ref), [`∩`](@ref), [`∪`](@ref). + # Examples ```jldoctest julia> issubset([1, 2], [1, 2, 3]) @@ -351,6 +361,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]) @@ -384,6 +396,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. """ diff --git a/base/accumulate.jl b/base/accumulate.jl index fe06dbc1c2c70..ce98f68d73062 100644 --- a/base/accumulate.jl +++ b/base/accumulate.jl @@ -204,6 +204,8 @@ Cumulative product of an iterator. See also [`cumprod!`](@ref) to use a preallocated output array, both for performance and to control the precision of the output (e.g. to avoid overflow). +See also [`cumprod!`](@ref), [`accumulate`](@ref), [`cumsum`](@ref). + !!! compat "Julia 1.5" `cumprod` on a non-array iterator requires at least Julia 1.5. diff --git a/base/array.jl b/base/array.jl index 854842e5132de..15636b4b5a777 100644 --- a/base/array.jl +++ b/base/array.jl @@ -343,6 +343,8 @@ end Create a shallow copy of `x`: the outer structure is copied, but not all internal values. For example, copying an array produces a new array with identically-same elements as the original. + +See also [`copy!`](@ref), [`copyto!`](@ref). """ copy @@ -420,6 +422,8 @@ array of floats, with each element initialized to `1.0`. `dims` may be specified as either a tuple or a sequence of arguments. For example, the common idiom `fill(x)` creates a zero-dimensional array containing the single value `x`. +See also: [`fill!`](@ref), [`zeros`](@ref), [`ones`](@ref), [`similar`](@ref). + # Examples ```jldoctest julia> fill(1.0, (2,3)) @@ -456,7 +460,7 @@ fill(v, dims::Tuple{}) = (a=Array{typeof(v),0}(undef, dims); fill!(a, v); a) zeros([T=Float64,] dims...) Create an `Array`, with element type `T`, of all zeros with size specified by `dims`. -See also [`fill`](@ref), [`ones`](@ref). +See also [`fill`](@ref), [`ones`](@ref), [`zero`](@ref). # Examples ```jldoctest @@ -906,6 +910,8 @@ collection to it. The result of the preceding example is equivalent to `append!( 5, 6])`. For `AbstractSet` objects, [`union!`](@ref) can be used instead. See [`sizehint!`](@ref) for notes about the performance model. + +See also [`pushfirst!`](@ref). """ function push! end @@ -955,6 +961,9 @@ themselves in another collection. The result of the preceding example is equival `push!([1, 2, 3], 4, 5, 6)`. See [`sizehint!`](@ref) for notes about the performance model. + +See also [`vcat`](@ref) for vectors, [`union!`](@ref) for sets, +and [`prepend!`](@ref) and [`pushfirst!`](@ref) for the opposite order. """ function append!(a::Vector, items::AbstractVector) itemindices = eachindex(items) diff --git a/base/combinatorics.jl b/base/combinatorics.jl index d966065852b3a..b9d2a3a451c03 100644 --- a/base/combinatorics.jl +++ b/base/combinatorics.jl @@ -228,6 +228,8 @@ invpermute!(a, p::AbstractVector) = invpermute!!(a, copymutable(p)) Return the inverse permutation of `v`. If `B = A[v]`, then `A == B[invperm(v)]`. +See also [`sortperm`](@ref), [`invpermute!`](@ref), [`isperm`](@ref), [`permutedims`](@ref). + # Examples ```jldoctest julia> v = [2; 4; 3; 1]; diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index 2465f69f1d970..b0326ad72a759 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -1846,6 +1846,8 @@ setfield! Get the concrete type of `x`. +See also [`eltype`](@ref). + # Examples ```jldoctest julia> a = 1//2; @@ -2007,7 +2009,9 @@ containing elements of type `T`. `N` can either be supplied explicitly, as in `Array{T,N}(undef, dims)`, or be determined by the length or number of `dims`. `dims` may be a tuple or a series of integer arguments corresponding to the lengths in each dimension. If the rank `N` is supplied explicitly, then it must -match the length or number of `dims`. See [`undef`](@ref). +match the length or number of `dims`. + +See also: [`undef`](@ref), [`similar`](@ref). # Examples ```julia-repl @@ -2096,6 +2100,8 @@ Alias for `UndefInitializer()`, which constructs an instance of the singleton ty [`UndefInitializer`](@ref), used in array initialization to indicate the array-constructor-caller would like an uninitialized array. +See also: [`missing`](@ref), [`similar`](@ref). + # Examples ```julia-repl julia> Array{Float64, 1}(undef, 3) diff --git a/base/float.jl b/base/float.jl index d28bc17601a2b..f67747865ea01 100644 --- a/base/float.jl +++ b/base/float.jl @@ -469,6 +469,8 @@ abs(x::Float64) = abs_float(x) Test whether a number value is a NaN, an indeterminate value which is neither an infinity nor a finite number ("not a number"). + +See also: [`iszero`](@ref), [`isone`](@ref), [`isinf`](@ref). """ isnan(x::AbstractFloat) = (x != x)::Bool isnan(x::Number) = false @@ -481,6 +483,8 @@ isfinite(x::Integer) = true isinf(f) -> Bool Test whether a number is infinite. + +See also: [`iszero`](@ref), [`isfinite`](@ref), [`isnan`](@ref). """ isinf(x::Real) = !isnan(x) & !isfinite(x) @@ -641,7 +645,7 @@ uabs(x::BitSigned) = unsigned(abs(x)) nextfloat(x::AbstractFloat, n::Integer) The result of `n` iterative applications of `nextfloat` to `x` if `n >= 0`, or `-n` -applications of `prevfloat` if `n < 0`. +applications of [`prevfloat`](@ref) if `n < 0`. """ function nextfloat(f::IEEEFloat, d::Integer) F = typeof(f) @@ -686,6 +690,8 @@ end Return the smallest floating point number `y` of the same type as `x` such `x < y`. If no such `y` exists (e.g. if `x` is `Inf` or `NaN`), then return `x`. + +See also: [`prevfloat`](@ref), [`eps`](@ref), [`issubnormal`](@ref). """ nextfloat(x::AbstractFloat) = nextfloat(x,1) @@ -693,7 +699,7 @@ nextfloat(x::AbstractFloat) = nextfloat(x,1) prevfloat(x::AbstractFloat, n::Integer) The result of `n` iterative applications of `prevfloat` to `x` if `n >= 0`, or `-n` -applications of `nextfloat` if `n < 0`. +applications of [`nextfloat`](@ref) if `n < 0`. """ prevfloat(x::AbstractFloat, d::Integer) = nextfloat(x, -d) @@ -813,6 +819,8 @@ floatmin(x::T) where {T<:AbstractFloat} = floatmin(T) Return the largest finite number representable by the floating-point type `T`. +See also: [`typemax`](@ref), [`floatmin`](@ref), [`eps`](@ref). + # Examples ```jldoctest julia> floatmax(Float16) @@ -877,6 +885,8 @@ is the nearest floating point number to ``y``, then |y-x| \\leq \\operatorname{eps}(x)/2. ``` +See also: [`nextfloat`](@ref), [`issubnormal`](@ref), [`floatmax`](@ref). + # Examples ```jldoctest julia> eps(1.0) diff --git a/base/int.jl b/base/int.jl index b3acd29c6492f..3d9851bd5947a 100644 --- a/base/int.jl +++ b/base/int.jl @@ -700,6 +700,8 @@ function typemin end The highest value representable by the given (real) numeric `DataType`. +See also: [`floatmax`](@ref), [`typemin`](@ref), [`eps`](@ref). + # Examples ```jldoctest julia> typemax(Int8) diff --git a/base/multidimensional.jl b/base/multidimensional.jl index 0fcd70b2d2a9e..b6ffe7c68777d 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -1159,6 +1159,8 @@ their indices; any offset results in a (circular) wraparound. If the arrays have overlapping indices, then on the domain of the overlap `dest` agrees with `src`. +See also: [`circshift`](@ref). + # Examples ```julia-repl julia> src = reshape(Vector(1:16), (4,4)) diff --git a/base/number.jl b/base/number.jl index 142796d3903ac..525e82d9330aa 100644 --- a/base/number.jl +++ b/base/number.jl @@ -25,6 +25,8 @@ isinteger(x::Integer) = true Return `true` if `x == zero(x)`; if `x` is an array, this checks whether all of the elements of `x` are zero. +See also: [`isone`](@ref), [`isinteger`](@ref), [`isfinite`](@ref), [`isnan`](@ref). + # Examples ```jldoctest julia> iszero(0.0) @@ -110,6 +112,8 @@ copy(x::Number) = x # some code treats numbers as collection-like Returns `true` if the value of the sign of `x` is negative, otherwise `false`. +See also [`sign`](@ref). + # Examples ```jldoctest julia> signbit(-4) @@ -131,6 +135,9 @@ signbit(x::Real) = x < 0 sign(x) Return zero if `x==0` and ``x/|x|`` otherwise (i.e., ±1 for real `x`). + +See also [`signbit`](@ref), [`zero`](@ref). + """ sign(x::Number) = iszero(x) ? x/abs(oneunit(x)) : x/abs(x) sign(x::Real) = ifelse(x < zero(x), oftype(one(x),-1), ifelse(x > zero(x), one(x), typeof(one(x))(x))) @@ -243,6 +250,8 @@ map(f, x::Number, ys::Number...) = f(x, ys...) Get the additive identity element for the type of `x` (`x` can also specify the type itself). +See also [`iszero`](@ref), [`one`](@ref), [`oneunit`](@ref), [`oftype`](@ref). + # Examples ```jldoctest julia> zero(1) diff --git a/base/permuteddimsarray.jl b/base/permuteddimsarray.jl index feffc17b8d7c4..785c9241a799c 100644 --- a/base/permuteddimsarray.jl +++ b/base/permuteddimsarray.jl @@ -24,7 +24,7 @@ Given an AbstractArray `A`, create a view `B` such that the dimensions appear to be permuted. Similar to `permutedims`, except that no copying occurs (`B` shares storage with `A`). -See also: [`permutedims`](@ref). +See also: [`permutedims`](@ref), [`invperm`](@ref). # Examples ```jldoctest @@ -86,7 +86,7 @@ end Permute the dimensions of array `A`. `perm` is a vector specifying a permutation of length `ndims(A)`. -See also: [`PermutedDimsArray`](@ref). +See also: [`permutedims!`](@ref), [`PermutedDimsArray`](@ref), [`transpose`](@ref), [`invperm`](@ref). # Examples ```jldoctest diff --git a/base/reducedim.jl b/base/reducedim.jl index 85807851cd23d..d8267131a4f4c 100644 --- a/base/reducedim.jl +++ b/base/reducedim.jl @@ -615,6 +615,8 @@ maximum(A::AbstractArray; dims) Compute the maximum value from of calling the function `f` on each element of an array over the given dimensions. +See also: [`maximum!`](@ref), [`extrema`](@ref). + # Examples ```jldoctest julia> A = [1 2; 3 4] diff --git a/base/reflection.jl b/base/reflection.jl index 9558731a277d1..e2386e09dc547 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -446,6 +446,8 @@ Return `true` iff value `v` is mutable. See [Mutable Composite Types](@ref) for a discussion of immutability. Note that this function works on values, so if you give it a type, it will tell you that a value of `DataType` is mutable. +See also [`isbits`](@ref). + # Examples ```jldoctest julia> ismutable(1) @@ -516,7 +518,7 @@ isbitstype(@nospecialize(t::Type)) = (@_pure_meta; isa(t, DataType) && t.isbitst """ isbits(x) -Return `true` if `x` is an instance of an `isbitstype` type. +Return `true` if `x` is an instance of an [`isbitstype`](@ref) type. """ isbits(@nospecialize x) = (@_pure_meta; typeof(x).isbitstype) diff --git a/base/show.jl b/base/show.jl index dc27d67582774..f350d8ed942e8 100644 --- a/base/show.jl +++ b/base/show.jl @@ -896,7 +896,9 @@ show_supertypes(typ::DataType) = show_supertypes(stdout, typ) """ @show -Show an expression and result, returning the result. See also [`show`](@ref). +Show an expression and result, returning the result. + +See also: [`show`](@ref), [`@info`](@ref). """ macro show(exs...) blk = Expr(:block) diff --git a/base/sort.jl b/base/sort.jl index 36601ebb70f92..f62c6a1141cc3 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -907,7 +907,7 @@ using the same keywords as [`sort!`](@ref). The permutation is guaranteed to be if the sorting algorithm is unstable, meaning that indices of equal elements appear in ascending order. -See also [`sortperm!`](@ref). +See also [`sortperm!`](@ref), [`partialsortperm`](@ref), [`invperm`](@ref). # Examples ```jldoctest diff --git a/stdlib/LinearAlgebra/src/dense.jl b/stdlib/LinearAlgebra/src/dense.jl index f6c8c34e5531a..56b92495550f3 100644 --- a/stdlib/LinearAlgebra/src/dense.jl +++ b/stdlib/LinearAlgebra/src/dense.jl @@ -75,7 +75,8 @@ isposdef!(A::AbstractMatrix) = Test whether a matrix is positive definite (and Hermitian) by trying to perform a Cholesky factorization of `A`. -See also [`isposdef!`](@ref) + +See also [`isposdef!`](@ref), [`cholesky`](@ref). # Examples ```jldoctest @@ -205,6 +206,8 @@ diagind(m::Integer, n::Integer, k::Integer=0) = An `AbstractRange` giving the indices of the `k`th diagonal of the matrix `M`. +See also: [`diag`](@ref), [`diagm`](@ref), [`Diagonal`](@ref). + # Examples ```jldoctest julia> A = [1 2 3; 4 5 6; 7 8 9] @@ -227,7 +230,7 @@ end The `k`th diagonal of a matrix, as a vector. -See also: [`diagm`](@ref) +See also: [`diagm`](@ref), [`diagind`](@ref), [`Diagonal`](@ref). # Examples ```jldoctest diff --git a/stdlib/LinearAlgebra/src/generic.jl b/stdlib/LinearAlgebra/src/generic.jl index f654bd4978060..21b011756aa0e 100644 --- a/stdlib/LinearAlgebra/src/generic.jl +++ b/stdlib/LinearAlgebra/src/generic.jl @@ -1541,6 +1541,8 @@ end Matrix determinant. +See also: [`logdet`](@ref) and [`logabsdet`](@ref). + # Examples ```jldoctest julia> M = [1 0; 2 2] From e292dbb73920f8fa5f813ad8264842e8aa5cd9de Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Sun, 29 Nov 2020 16:20:10 +0100 Subject: [PATCH 02/28] similar & undef --- base/docs/basedocs.jl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index b0326ad72a759..8c147149c7873 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -2016,14 +2016,19 @@ See also: [`undef`](@ref), [`similar`](@ref). # Examples ```julia-repl julia> A = Array{Float64, 2}(undef, 2, 3) # N given explicitly -2×3 Array{Float64, 2}: +2×3 Matrix{Float64}: 6.90198e-310 6.90198e-310 6.90198e-310 6.90198e-310 6.90198e-310 0.0 julia> B = Array{Float64}(undef, 2) # N determined by the input -2-element Array{Float64, 1}: +2-element Vector{Float64}: 1.87103e-320 0.0 + +julia> similar(A, Int16) # +2×3 Matrix{Int16}: + -14496 1 74 + 16160 0 0 ``` """ Array{T,N}(::UndefInitializer, dims) @@ -2105,7 +2110,7 @@ See also: [`missing`](@ref), [`similar`](@ref). # Examples ```julia-repl julia> Array{Float64, 1}(undef, 3) -3-element Array{Float64, 1}: +3-element Vector{Float64}: 2.2752528595e-314 2.202942107e-314 2.275252907e-314 From 09b8615d3e6a619186b9320c98611e8f10a44384 Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Sun, 29 Nov 2020 16:20:43 +0100 Subject: [PATCH 03/28] permute with tuples --- base/combinatorics.jl | 5 +++++ base/permuteddimsarray.jl | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/base/combinatorics.jl b/base/combinatorics.jl index b9d2a3a451c03..50e800684aff8 100644 --- a/base/combinatorics.jl +++ b/base/combinatorics.jl @@ -232,6 +232,11 @@ See also [`sortperm`](@ref), [`invpermute!`](@ref), [`isperm`](@ref), [`permuted # Examples ```jldoctest +julia> p = (2, 3, 1); + +julia> invperm(p) +(3, 1, 2) + julia> v = [2; 4; 3; 1]; julia> invperm(v) diff --git a/base/permuteddimsarray.jl b/base/permuteddimsarray.jl index 785c9241a799c..4a5d19d8d2f74 100644 --- a/base/permuteddimsarray.jl +++ b/base/permuteddimsarray.jl @@ -83,8 +83,8 @@ end """ permutedims(A::AbstractArray, perm) -Permute the dimensions of array `A`. `perm` is a vector specifying a permutation of length -`ndims(A)`. +Permute the dimensions of array `A`. `perm` is a vector or a tuple of length `ndims(A)`, +specifying the permutation. See also: [`permutedims!`](@ref), [`PermutedDimsArray`](@ref), [`transpose`](@ref), [`invperm`](@ref). @@ -100,7 +100,7 @@ julia> A = reshape(Vector(1:8), (2,2,2)) 5 7 6 8 -julia> permutedims(A, [3, 2, 1]) +julia> permutedims(A, (3, 2, 1)) 2×2×2 Array{Int64, 3}: [:, :, 1] = 1 3 @@ -109,6 +109,16 @@ julia> permutedims(A, [3, 2, 1]) [:, :, 2] = 2 4 6 8 + +julia> B = randn(5, 7, 11, 13); + +julia> perm = [4,1,3,2]; + +julia> size(permutedims(B, perm)) +(13, 5, 11, 7) + +julia> size(B)[perm] == ans +true ``` """ function permutedims(A::AbstractArray, perm) From fd50bab5f98e2ab3443937e1df3bfb644c38e1c5 Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Sun, 29 Nov 2020 16:21:01 +0100 Subject: [PATCH 04/28] sign doctest --- base/number.jl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/base/number.jl b/base/number.jl index 525e82d9330aa..a0f20f9cb22b3 100644 --- a/base/number.jl +++ b/base/number.jl @@ -138,6 +138,20 @@ Return zero if `x==0` and ``x/|x|`` otherwise (i.e., ±1 for real `x`). See also [`signbit`](@ref), [`zero`](@ref). +# Examples +```jldoctest +julia> sign(-4.0) +-1.0 + +julia> sign(99) +1 + +julia> sign(-0.0) +-0.0 + +julia> sign(0 + im) +0.0 + 1.0im +``` """ sign(x::Number) = iszero(x) ? x/abs(oneunit(x)) : x/abs(x) sign(x::Real) = ifelse(x < zero(x), oftype(one(x),-1), ifelse(x > zero(x), one(x), typeof(one(x))(x))) From bbf7d5735b1546348be6580f7246c10e675efc35 Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Sun, 29 Nov 2020 16:21:30 +0100 Subject: [PATCH 05/28] collect & comprehensions --- base/array.jl | 9 +++++++++ base/iterators.jl | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/base/array.jl b/base/array.jl index 15636b4b5a777..17688b37537a0 100644 --- a/base/array.jl +++ b/base/array.jl @@ -590,6 +590,8 @@ Return an `Array` of all items in a collection or iterator. For dictionaries, re [`HasShape`](@ref IteratorSize) trait, the result will have the same shape and number of dimensions as the argument. +Used by comprehensions to turn a generator into an `Array`. + # Examples ```jldoctest julia> collect(1:2:13) @@ -601,6 +603,13 @@ julia> collect(1:2:13) 9 11 13 + +julia> [x^2 for x in 1:8 if isodd(x)] +4-element Vector{Int64}: + 1 + 9 + 25 + 49 ``` """ collect(itr) = _collect(1:1 #= Array =#, itr, IteratorEltype(itr), IteratorSize(itr)) diff --git a/base/iterators.jl b/base/iterators.jl index af5e108845afb..72cdb53c59cb7 100644 --- a/base/iterators.jl +++ b/base/iterators.jl @@ -441,6 +441,12 @@ julia> foreach(println, f) 1 3 5 + +julia> [x for x in [1, 2, 3, 4, 5] if isodd(x)] # collects a generator over Iterators.filter +3-element Vector{Int64}: + 1 + 3 + 5 ``` """ filter(flt, itr) = Filter(flt, itr) @@ -925,6 +931,9 @@ julia> collect(Iterators.product(1:2, 3:5)) 2×3 Matrix{Tuple{Int64, Int64}}: (1, 3) (1, 4) (1, 5) (2, 3) (2, 4) (2, 5) + +julia> ans == [(x,y) for x in 1:2, y in 3:5] # lowers to the same code +true ``` """ product(iters...) = ProductIterator(iters) From c604eeaac2875aaedbbdf5cfd5ac72c4e6b8d0ce Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Sun, 29 Nov 2020 16:25:26 +0100 Subject: [PATCH 06/28] typemax & floatmax --- base/float.jl | 3 +++ base/int.jl | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/base/float.jl b/base/float.jl index f67747865ea01..34dca2bd087ee 100644 --- a/base/float.jl +++ b/base/float.jl @@ -831,6 +831,9 @@ julia> floatmax(Float32) julia> floatmax() 1.7976931348623157e308 + +julia> typemax(Float64) +Inf ``` """ floatmax(x::T) where {T<:AbstractFloat} = floatmax(T) diff --git a/base/int.jl b/base/int.jl index 3d9851bd5947a..03d155086bd8e 100644 --- a/base/int.jl +++ b/base/int.jl @@ -709,6 +709,12 @@ julia> typemax(Int8) julia> typemax(UInt32) 0xffffffff + +julia> typemax(Float64) +Inf + +julia> floatmax(Float32) # largest finite floating point number +3.4028235f38 ``` """ function typemax end From 76226f29b4e87a8c1686ac4b8e00fabf71872c46 Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Wed, 2 Dec 2020 14:03:52 +0100 Subject: [PATCH 07/28] add some examples --- base/abstractarray.jl | 41 +++++++++++++++++++++------- base/div.jl | 8 ++++++ base/docs/basedocs.jl | 62 +++++++++++++++++++++++++++++++++---------- base/float.jl | 27 +++++++++++++++++++ base/int.jl | 4 +++ base/iterators.jl | 9 +++++++ base/math.jl | 7 +++++ base/mathconstants.jl | 24 +++++++++++++++++ base/number.jl | 10 +++++-- base/operators.jl | 8 ++++++ base/promotion.jl | 11 +++++++- base/reflection.jl | 3 +++ base/set.jl | 3 +++ base/show.jl | 14 ++++++++-- 14 files changed, 202 insertions(+), 29 deletions(-) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 27d3226f3a623..0d6179b254bb6 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -353,6 +353,9 @@ 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. + # Examples ```jldoctest julia> firstindex([1,2,4]) @@ -2127,18 +2130,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," & ",y), tri, 1:100) +1 & 1 +4 & 2 +7 & 3 ``` """ foreach(f) = (f(); nothing) @@ -2307,7 +2320,7 @@ 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: [`map!`](@ref), [`foreach`](@ref), [`mapreduce`](@ref), [`mapslices`](@ref). @@ -2319,7 +2332,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 @@ -2364,7 +2377,7 @@ 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. # Examples ```jldoctest @@ -2377,6 +2390,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} diff --git a/base/div.jl b/base/div.jl index 34b60539448f6..cff322edc65be 100644 --- a/base/div.jl +++ b/base/div.jl @@ -81,6 +81,10 @@ See also: [`div`](@ref) ```jldoctest julia> fld(7.3,5.5) 1.0 + +julia> fld.(-5:5, 3)' +1×11 adjoint(::Vector{Int64}) with eltype Int64: + -2 -2 -1 -1 -1 0 0 0 1 1 1 ``` Because `fld(x, y)` implements strictly correct floored rounding based on the true value of floating-point numbers, unintuitive situations can arise. For example: @@ -111,6 +115,10 @@ See also: [`div`](@ref) ```jldoctest julia> cld(5.5,2.2) 3.0 + +julia> cld.(-5:5, 3)' +1×11 adjoint(::Vector{Int64}) with eltype Int64: + -1 -1 -1 0 0 0 1 1 1 2 2 ``` """ cld(a, b) = div(a, b, RoundUp) diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index 8c147149c7873..6ea19771da72b 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -673,7 +673,7 @@ See the manual section on [control flow](@ref man-conditional-evaluation) for mo ``` julia> x = 1; y = 2; -julia> println(x > y ? "x is larger" : "y is larger") +julia> x > y ? println("x is larger") : println("y is larger") y is larger ``` """ @@ -930,6 +930,17 @@ kw";" x && y Short-circuiting boolean AND. + +# Examples +```jldoctest +julia> x = 3; + +julia> x > 1 && x < 10 && x isa Int +true + +julia> x < 0 && error("expected positive x") +false +``` """ kw"&&" @@ -937,6 +948,15 @@ kw"&&" x || y Short-circuiting boolean OR. + +# Examples +```jldoctest +julia> pi < 3 || ℯ < 3 +true + +julia> false || true || println("neither is true!") +true +``` """ kw"||" @@ -1782,8 +1802,14 @@ Construct a tuple of the given objects. # Examples ```jldoctest -julia> tuple(1, 'a', pi) -(1, 'a', π) +julia> tuple(1, 'b', pi) +(1, 'b', π) + +julia> ans === (1, 'b', π) +true + +julia> Tuple([1, 2, pi]) # takes a collection +(1.0, 2.0, 3.141592653589793) ``` """ tuple @@ -1960,8 +1986,13 @@ Construct an uninitialized [`Matrix{T}`](@ref) of size `m`×`n`. See [`undef`](@ ```julia-repl julia> Matrix{Float64}(undef, 2, 3) 2×3 Array{Float64, 2}: - 6.93517e-310 6.93517e-310 6.93517e-310 - 6.93517e-310 6.93517e-310 1.29396e-320 + 2.36365e-314 2.28473e-314 5.0e-324 + 2.26704e-314 2.26711e-314 NaN + +julia> similar(ans, Int32, 2, 2) +2×2 Matrix{Int32}: + 490537216 1277177453 + 1 1936748399 ``` """ Matrix{T}(::UndefInitializer, m, n) @@ -2020,15 +2051,18 @@ julia> A = Array{Float64, 2}(undef, 2, 3) # N given explicitly 6.90198e-310 6.90198e-310 6.90198e-310 6.90198e-310 6.90198e-310 0.0 -julia> B = Array{Float64}(undef, 2) # N determined by the input -2-element Vector{Float64}: - 1.87103e-320 - 0.0 - -julia> similar(A, Int16) # -2×3 Matrix{Int16}: - -14496 1 74 - 16160 0 0 +julia> B = Array{Float64}(undef, 4) # N determined by the input +4-element Vector{Float64}: + 2.360075077e-314 + NaN + 2.2671131793e-314 + 2.299821756e-314 + +julia> similar(B, 2, 4, 1) # use typeof(B), and the given size +2×4×1 Array{Float64, 3}: +[:, :, 1] = + 2.26703e-314 2.26708e-314 0.0 2.80997e-314 + 0.0 2.26703e-314 2.26708e-314 0.0 ``` """ Array{T,N}(::UndefInitializer, dims) diff --git a/base/float.jl b/base/float.jl index 34dca2bd087ee..47349f91c3c26 100644 --- a/base/float.jl +++ b/base/float.jl @@ -36,6 +36,15 @@ const Inf = Inf64 Inf, Inf64 Positive infinity of type [`Float64`](@ref). + +# Examples +```jldoctest +julia> π/0 +Inf + +julia> ℯ^-Inf +0.0 +``` """ Inf, Inf64 @@ -44,6 +53,15 @@ const NaN = NaN64 NaN, NaN64 A not-a-number value of type [`Float64`](@ref). + +# Examples +```jldoctest +julia> 0/0 +NaN + +julia> Inf - Inf +NaN +``` """ NaN, NaN64 @@ -226,6 +244,15 @@ Bool(x::Float16) = x==0 ? false : x==1 ? true : throw(InexactError(:Bool, Bool, float(x) Convert a number or array to a floating point data type. + +# Examples +```jldoctest +julia> float(1:1000) +1.0:1.0:1000.0 + +julia> float(typemax(Int32)) +2.147483647e9 +``` """ float(x) = AbstractFloat(x) diff --git a/base/int.jl b/base/int.jl index 03d155086bd8e..2ca38ffef00c8 100644 --- a/base/int.jl +++ b/base/int.jl @@ -246,6 +246,10 @@ julia> mod(eps(), 3) julia> mod(-eps(), 3) 3.0 + +julia> mod.(-5:5, 3)' +1×11 adjoint(::Vector{Int64}) with eltype Int64: + 1 2 0 1 2 0 1 2 0 1 2 ``` """ function mod(x::T, y::T) where T<:Integer diff --git a/base/iterators.jl b/base/iterators.jl index 72cdb53c59cb7..1a94c3ffc7c96 100644 --- a/base/iterators.jl +++ b/base/iterators.jl @@ -1063,6 +1063,15 @@ julia> collect(Iterators.flatten((1:2, 8:9))) 2 8 9 + +julia> [(x,y) for x in 0:1 for y in 'a':'c'] # collects generators involving Iterators.flatten +6-element Vector{Tuple{Int64, Char}}: + (0, 'a') + (0, 'b') + (0, 'c') + (1, 'a') + (1, 'b') + (1, 'c') ``` """ flatten(itr) = Flatten(itr) diff --git a/base/math.jl b/base/math.jl index 4497e3f4d9a9b..a6ff6303fbab4 100644 --- a/base/math.jl +++ b/base/math.jl @@ -612,6 +612,13 @@ Stacktrace: julia> sqrt(big(complex(-81))) 0.0 + 9.0im + +julia> .√(1:4) +4-element Vector{Float64}: + 1.0 + 1.4142135623730951 + 1.7320508075688772 + 2.0 ``` """ sqrt(x::Real) = sqrt(float(x)) diff --git a/base/mathconstants.jl b/base/mathconstants.jl index a3d1be99becbb..643e27a364e0c 100644 --- a/base/mathconstants.jl +++ b/base/mathconstants.jl @@ -23,10 +23,15 @@ Base.@irrational catalan 0.91596559417721901505 catalan The constant pi. +Unicode `π` can be typed by tab-completing `\\pi` in the Julia REPL. + # Examples ```jldoctest julia> pi π = 3.1415926535897... + +julia> 1/2pi +0.15915494309189535 ``` """ π, const pi = π @@ -37,10 +42,18 @@ julia> pi The constant ℯ. +Unicode `ℯ` can be typed by tab-completing `\\euler` in the Julia REPL. + # Examples ```jldoctest julia> ℯ ℯ = 2.7182818284590... + +julia> log(ℯ) +1 + +julia> ℯ^(im)π ≈ -1 +true ``` """ ℯ, const e = ℯ @@ -55,6 +68,11 @@ Euler's constant. ```jldoctest julia> Base.MathConstants.eulergamma γ = 0.5772156649015... + +julia> dx = 10^-6; + +julia> sum(-exp(-x) * log(x) for x in dx:dx:100) * dx +0.5772078382499134 ``` """ γ, const eulergamma = γ @@ -69,6 +87,9 @@ The golden ratio. ```jldoctest julia> Base.MathConstants.golden φ = 1.6180339887498... + +julia> (2ans - 1)^2 ≈ 5 +true ``` """ φ, const golden = φ @@ -82,6 +103,9 @@ Catalan's constant. ```jldoctest julia> Base.MathConstants.catalan catalan = 0.9159655941772... + +julia> sum(log(x)/(1+x^2) for x in 1:0.01:10^6) * 0.01 +0.9159466120554123 ``` """ catalan diff --git a/base/number.jl b/base/number.jl index a0f20f9cb22b3..150f36c46535e 100644 --- a/base/number.jl +++ b/base/number.jl @@ -245,8 +245,14 @@ Multiply `x` and `y`, giving the result as a larger type. # Examples ```jldoctest -julia> widemul(Float32(3.), 4.) -12.0 +julia> widemul(Float32(3.0), 4.0) isa BigFloat +true + +julia> typemax(Int8) * typemax(Int8) +1 + +julia> widemul(typemax(Int8), typemax(Int8)) # == 127^2 +16129 ``` """ widemul(x::Number, y::Number) = widen(x)*widen(y) diff --git a/base/operators.jl b/base/operators.jl index a35c44276a2e4..99258c5341dc7 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -773,6 +773,10 @@ julia> x % y julia> x == div(x, y) * y + rem(x, y) true + +julia> rem.(-5:5, 3)' +1×11 adjoint(::Vector{Int64}) with eltype Int64: + -2 -1 0 -2 -1 0 1 2 0 1 2 ``` """ rem @@ -794,6 +798,10 @@ julia> -5 ÷ 3 julia> 5.0 ÷ 2 2.0 + +julia> div.(-5:5, 3)' +1×11 adjoint(::Vector{Int64}) with eltype Int64: + -1 -1 -1 0 0 0 0 0 1 1 1 ``` """ div diff --git a/base/promotion.jl b/base/promotion.jl index a6e6d8fdcac4e..c7abacf68db4a 100644 --- a/base/promotion.jl +++ b/base/promotion.jl @@ -144,6 +144,15 @@ end Compute a type that contains both `T` and `S`, which could be either a parent of both types, or a `Union` if appropriate. Falls back to [`typejoin`](@ref). + +# Examples +```jldoctest +julia> Base.promote_typejoin(Int, Float64) +Real + +julia> Base.promote_type(Int, Float64) +Float64 +``` """ function promote_typejoin(@nospecialize(a), @nospecialize(b)) c = typejoin(_promote_typesubtract(a), _promote_typesubtract(b)) @@ -335,7 +344,7 @@ where usually `^ == Base.^` unless `^` has been defined in the calling namespace.) If `y` is a negative integer literal, then `Base.literal_pow` transforms the operation to `inv(x)^-y` by default, where `-y` is positive. - +# Examples ```jldoctest julia> 3^5 243 diff --git a/base/reflection.jl b/base/reflection.jl index e2386e09dc547..fb4fe94d0639a 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -171,6 +171,9 @@ Get a tuple with the names of the fields of a `DataType`. ```jldoctest julia> fieldnames(Rational) (:num, :den) + +julia> fieldnames(typeof(1+im)) +(:re, :im) ``` """ fieldnames(t::DataType) = (fieldcount(t); # error check to make sure type is specific enough diff --git a/base/set.jl b/base/set.jl index fb837fbf86166..870da3f930b74 100644 --- a/base/set.jl +++ b/base/set.jl @@ -379,6 +379,9 @@ julia> a = [1; 2; 3] 2 3 +julia> allunique(a) +true + julia> allunique([a, a]) false ``` diff --git a/base/show.jl b/base/show.jl index f350d8ed942e8..7303158eda6f7 100644 --- a/base/show.jl +++ b/base/show.jl @@ -894,11 +894,21 @@ end show_supertypes(typ::DataType) = show_supertypes(stdout, typ) """ - @show + @show exs... -Show an expression and result, returning the result. +Prints one or more expressions, and their results, to `stdout`, and returns the last result. See also: [`show`](@ref), [`@info`](@ref). +# Examples +```jldoctest +julia> x = @show 1+2 +1 + 2 = 3 +3 + +julia> @show x^2 x/2; +x ^ 2 = 9 +x / 2 = 1.5 +``` """ macro show(exs...) blk = Expr(:block) From 6dbc68f27e05ddbb657a4963bfce90e7793a5551 Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Thu, 10 Dec 2020 17:50:50 +0100 Subject: [PATCH 08/28] amendments & corrections --- base/abstractarraymath.jl | 4 ++-- base/abstractset.jl | 4 ++-- base/array.jl | 5 +++-- base/float.jl | 4 ++-- base/iterators.jl | 2 +- base/missing.jl | 2 +- base/number.jl | 2 +- base/operators.jl | 2 +- base/reducedim.jl | 4 ++-- base/reflection.jl | 2 +- base/set.jl | 2 +- base/show.jl | 3 ++- base/some.jl | 2 +- base/sort.jl | 2 +- base/strings/util.jl | 4 ++-- stdlib/LinearAlgebra/src/dense.jl | 2 +- 16 files changed, 24 insertions(+), 22 deletions(-) diff --git a/base/abstractarraymath.jl b/base/abstractarraymath.jl index cad1b3f67ef74..4c4e925bed887 100644 --- a/base/abstractarraymath.jl +++ b/base/abstractarraymath.jl @@ -138,7 +138,7 @@ 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). +See also: [`circshift!`](@ref), [`circcopy!`](@ref), [`bitrotate`](@ref), [`<<`](@ref). # Examples ```jldoctest @@ -392,7 +392,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. diff --git a/base/abstractset.jl b/base/abstractset.jl index 86b54d16fe6d0..81db69d8940d3 100644 --- a/base/abstractset.jl +++ b/base/abstractset.jl @@ -13,7 +13,7 @@ copy!(dst::AbstractSet, src::AbstractSet) = union!(empty!(dst), src) Construct the union of sets. Maintain order with arrays. -See also: [`vcat`](@ref), [`intersect`](@ref), [`isdisjoint`](@ref). +See also: [`intersect`](@ref), [`isdisjoint`](@ref), [`vcat`](@ref), [`Iterators.flatten`](@ref). # Examples ```jldoctest @@ -254,7 +254,7 @@ function ⊇ end Determine whether every element of `a` is also in `b`, using [`in`](@ref). -See also [`⊈`](@ref) and [`⊉`](@ref), [`∩`](@ref), [`∪`](@ref). +See also [`⊈`](@ref), [`∩`](@ref intersect), [`∪`](@ref union), [`contains`](@ref). # Examples ```jldoctest diff --git a/base/array.jl b/base/array.jl index 17688b37537a0..0ba9d2e2ddc06 100644 --- a/base/array.jl +++ b/base/array.jl @@ -344,7 +344,7 @@ Create a shallow copy of `x`: the outer structure is copied, but not all interna For example, copying an array produces a new array with identically-same elements as the original. -See also [`copy!`](@ref), [`copyto!`](@ref). +See also [`copy!`](@ref Base.copy!), [`copyto!`](@ref). """ copy @@ -1195,7 +1195,8 @@ Remove the item at the given `i` and return it. Subsequent items are shifted to fill the resulting gap. When `i` is not a valid index for `a`, return `default`, or throw an error if `default` is not specified. -See also [`deleteat!`](@ref) and [`splice!`](@ref). + +See also: [`pop!`](@ref), [`popfirst!`](@ref), [`deleteat!`](@ref), [`splice!`](@ref). !!! compat "Julia 1.5" This function is available as of Julia 1.5. diff --git a/base/float.jl b/base/float.jl index 47349f91c3c26..42ec0ad223a74 100644 --- a/base/float.jl +++ b/base/float.jl @@ -497,7 +497,7 @@ abs(x::Float64) = abs_float(x) Test whether a number value is a NaN, an indeterminate value which is neither an infinity nor a finite number ("not a number"). -See also: [`iszero`](@ref), [`isone`](@ref), [`isinf`](@ref). +See also: [`iszero`](@ref), [`isone`](@ref), [`isinf`](@ref), [`ismissing`](@ref). """ isnan(x::AbstractFloat) = (x != x)::Bool isnan(x::Number) = false @@ -511,7 +511,7 @@ isfinite(x::Integer) = true Test whether a number is infinite. -See also: [`iszero`](@ref), [`isfinite`](@ref), [`isnan`](@ref). +See also: [`Inf`](@ref), [`iszero`](@ref), [`isfinite`](@ref), [`isnan`](@ref). """ isinf(x::Real) = !isnan(x) & !isfinite(x) diff --git a/base/iterators.jl b/base/iterators.jl index 1a94c3ffc7c96..109e0838710f1 100644 --- a/base/iterators.jl +++ b/base/iterators.jl @@ -932,7 +932,7 @@ julia> collect(Iterators.product(1:2, 3:5)) (1, 3) (1, 4) (1, 5) (2, 3) (2, 4) (2, 5) -julia> ans == [(x,y) for x in 1:2, y in 3:5] # lowers to the same code +julia> ans == [(x,y) for x in 1:2, y in 3:5] # collects a generator involving Iterators.product true ``` """ diff --git a/base/missing.jl b/base/missing.jl index ec92280b2d045..33e8fb3d8d2cc 100644 --- a/base/missing.jl +++ b/base/missing.jl @@ -394,7 +394,7 @@ end Return the first value in the arguments which is not equal to [`missing`](@ref), if any. Otherwise return `missing`. -See also [`something`](@ref). +See also [`skipmissing`](@ref), [`something`](@ref). # Examples diff --git a/base/number.jl b/base/number.jl index 150f36c46535e..b2c6df7f7a223 100644 --- a/base/number.jl +++ b/base/number.jl @@ -136,7 +136,7 @@ signbit(x::Real) = x < 0 Return zero if `x==0` and ``x/|x|`` otherwise (i.e., ±1 for real `x`). -See also [`signbit`](@ref), [`zero`](@ref). +See also [`signbit`](@ref), [`zero`](@ref), [`copysign`](@ref), [`flipsign`](@ref). # Examples ```jldoctest diff --git a/base/operators.jl b/base/operators.jl index 99258c5341dc7..9882e50264267 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -657,7 +657,7 @@ julia> bitstring(Int8(3)) julia> bitstring(Int8(12)) "00001100" ``` -See also [`>>`](@ref), [`>>>`](@ref). +See also [`>>`](@ref), [`>>>`](@ref), [`exp2`](@ref), [`ldexp`](@ref). """ function <<(x::Integer, c::Integer) @_inline_meta diff --git a/base/reducedim.jl b/base/reducedim.jl index d8267131a4f4c..855a5be6c48bf 100644 --- a/base/reducedim.jl +++ b/base/reducedim.jl @@ -590,6 +590,8 @@ Compute the maximum value of an array over the given dimensions. See also the [`max(a,b)`](@ref) function to take the maximum of two or more arguments, which can be applied elementwise to arrays via `max.(a,b)`. +See also: [`maximum!`](@ref), [`extrema`](@ref), [`findmax`](@ref), [`argmax`](@ref). + # Examples ```jldoctest julia> A = [1 2; 3 4] @@ -615,8 +617,6 @@ maximum(A::AbstractArray; dims) Compute the maximum value from of calling the function `f` on each element of an array over the given dimensions. -See also: [`maximum!`](@ref), [`extrema`](@ref). - # Examples ```jldoctest julia> A = [1 2; 3 4] diff --git a/base/reflection.jl b/base/reflection.jl index fb4fe94d0639a..fff6abafa62ae 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -449,7 +449,7 @@ Return `true` iff value `v` is mutable. See [Mutable Composite Types](@ref) for a discussion of immutability. Note that this function works on values, so if you give it a type, it will tell you that a value of `DataType` is mutable. -See also [`isbits`](@ref). +See also [`isbits`](@ref), [`isstructtype`](@ref). # Examples ```jldoctest diff --git a/base/set.jl b/base/set.jl index 870da3f930b74..4f16825a3de89 100644 --- a/base/set.jl +++ b/base/set.jl @@ -540,7 +540,7 @@ of the result will not include singleton types which are replaced with values of a different type: for example, `Union{T,Missing}` will become `T` if `missing` is replaced. -See also [`replace!`](@ref). +See also [`replace!`](@ref), [`splice!`](@ref), [`delete!`](@ref), [`insert!`](@ref). # Examples ```jldoctest diff --git a/base/show.jl b/base/show.jl index 7303158eda6f7..9ecb3c5d09073 100644 --- a/base/show.jl +++ b/base/show.jl @@ -898,7 +898,8 @@ show_supertypes(typ::DataType) = show_supertypes(stdout, typ) Prints one or more expressions, and their results, to `stdout`, and returns the last result. -See also: [`show`](@ref), [`@info`](@ref). +See also: [`show`](@ref), [`@info`](@ref Logging.@logmsg), [`println`](@ref). + # Examples ```jldoctest julia> x = @show 1+2 diff --git a/base/some.jl b/base/some.jl index 041c3359e0433..19289a4408da5 100644 --- a/base/some.jl +++ b/base/some.jl @@ -74,7 +74,7 @@ Return the first value in the arguments which is not equal to [`nothing`](@ref), if any. Otherwise throw an error. Arguments of type [`Some`](@ref) are unwrapped. -See also [`coalesce`](@ref). +See also [`coalesce`](@ref), [`skipmissing`](@ref). # Examples ```jldoctest diff --git a/base/sort.jl b/base/sort.jl index f62c6a1141cc3..e92441b2c99b8 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -907,7 +907,7 @@ using the same keywords as [`sort!`](@ref). The permutation is guaranteed to be if the sorting algorithm is unstable, meaning that indices of equal elements appear in ascending order. -See also [`sortperm!`](@ref), [`partialsortperm`](@ref), [`invperm`](@ref). +See also [`sortperm!`](@ref), [`partialsortperm`](@ref), [`invperm`](@ref), [`indexin`](@ref). # Examples ```jldoctest diff --git a/base/strings/util.jl b/base/strings/util.jl index cb611ce5f0db9..04c4f3c4089d2 100644 --- a/base/strings/util.jl +++ b/base/strings/util.jl @@ -10,7 +10,7 @@ const Chars = Union{AbstractChar,Tuple{Vararg{AbstractChar}},AbstractVector{<:Ab Return `true` if `s` starts with `prefix`. If `prefix` is a vector or set of characters, test whether the first character of `s` belongs to that set. -See also [`endswith`](@ref). +See also [`endswith`](@ref), [`contains`](@ref). # Examples ```jldoctest @@ -30,7 +30,7 @@ startswith(str::AbstractString, chars::Chars) = !isempty(str) && first(str)::Abs Return `true` if `s` ends with `suffix`. If `suffix` is a vector or set of characters, test whether the last character of `s` belongs to that set. -See also [`startswith`](@ref). +See also [`startswith`](@ref), [`contains`](@ref). # Examples ```jldoctest diff --git a/stdlib/LinearAlgebra/src/dense.jl b/stdlib/LinearAlgebra/src/dense.jl index 56b92495550f3..96a11e574c5e6 100644 --- a/stdlib/LinearAlgebra/src/dense.jl +++ b/stdlib/LinearAlgebra/src/dense.jl @@ -230,7 +230,7 @@ end The `k`th diagonal of a matrix, as a vector. -See also: [`diagm`](@ref), [`diagind`](@ref), [`Diagonal`](@ref). +See also: [`diagm`](@ref), [`diagind`](@ref), [`Diagonal`](@ref), [`isdiag`](@ref). # Examples ```jldoctest From 488777985a26eb51c3c5a909922cf1ca1a8d77d0 Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Thu, 10 Dec 2020 17:51:42 +0100 Subject: [PATCH 09/28] another batch of see also additions --- base/abstractarray.jl | 33 +++- base/abstractarraymath.jl | 8 +- base/array.jl | 166 +++++++++++++++++- base/bool.jl | 2 + base/complex.jl | 17 ++ base/div.jl | 8 +- base/docs/basedocs.jl | 26 ++- base/essentials.jl | 12 +- base/file.jl | 12 ++ base/float.jl | 6 + base/hashing.jl | 6 +- base/iddict.jl | 2 +- base/int.jl | 27 ++- base/irrationals.jl | 4 +- base/iterators.jl | 14 ++ base/math.jl | 20 +++ base/mathconstants.jl | 4 + base/missing.jl | 2 + base/number.jl | 4 + base/operators.jl | 14 +- base/promotion.jl | 8 +- base/reduce.jl | 10 ++ base/reducedim.jl | 2 + base/reflection.jl | 20 +++ base/set.jl | 6 + base/some.jl | 2 + base/sort.jl | 4 + base/special/trig.jl | 8 + base/strings/io.jl | 4 + base/strings/util.jl | 6 + base/threadingconstructs.jl | 4 + base/tuple.jl | 4 + .../InteractiveUtils/src/InteractiveUtils.jl | 6 + stdlib/InteractiveUtils/src/macros.jl | 8 +- stdlib/LinearAlgebra/src/generic.jl | 2 + 35 files changed, 457 insertions(+), 24 deletions(-) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 0d6179b254bb6..ad563b64c3b3b 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -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 @@ -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)); @@ -75,6 +79,8 @@ end Return the tuple of valid indices for array `A`. +See also: [`size`](@ref), [`keys`](@ref), [`eachindex`](@ref). + # Examples ```jldoctest @@ -173,6 +179,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))) @@ -201,6 +209,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)); @@ -219,6 +229,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) @@ -335,6 +347,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]) @@ -356,6 +370,8 @@ Return the first index of `collection`. If `d` is given, return the first index 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]) @@ -376,7 +392,7 @@ 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). +See also: [`only`](@ref), [`firstindex`](@ref), [`last`](@ref), [`tail`](@ref Base.tail). # Examples ```jldoctest @@ -399,6 +415,8 @@ end Get the first `n` elements of the iterable collection `itr`, or fewer elements if `v` is not long enough. +See also: [`startswith`](@ref), [`Iterators.take`](@ref). + # Examples ```jldoctest julia> first(["foo", "bar", "qux"], 2) @@ -427,7 +445,7 @@ 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). +See also [`first`](@ref), [`endswith`](@ref). # Examples ```jldoctest @@ -741,7 +759,7 @@ julia> similar(falses(10), Float64, 2, 4) 2.18425e-314 2.18425e-314 2.18425e-314 2.18425e-314 ``` -See also: [`undef`](@ref). +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))) @@ -797,7 +815,7 @@ 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). +See also: [`empty!`](@ref), [`isempty`](@ref), [`isassigned`](@ref). # Examples @@ -931,12 +949,11 @@ 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), [`copy`](@ref). +See also [`copy!`](@ref Base.copy!), [`copy`](@ref). # Examples ```jldoctest @@ -2322,7 +2339,7 @@ mapany(f, itr) = Any[f(x) for x in itr] Transform collection `c` by applying `f` to each element. For multiple collection arguments, apply `f` elementwise, and stop when when any of them is exhausted. -See also: [`map!`](@ref), [`foreach`](@ref), [`mapreduce`](@ref), [`mapslices`](@ref). +See also: [`map!`](@ref), [`foreach`](@ref), [`mapreduce`](@ref), [`mapslices`](@ref), [`zip`](@ref), [`Iterators.map`](@ref). # Examples ```jldoctest @@ -2379,6 +2396,8 @@ end Like [`map`](@ref), but stores the result in `destination` rather than a new collection. `destination` must be at least as large as the smallest collection. +See also: [`map`](@ref), [`foreach`](@ref), [`zip`](@ref), [`copyto!`](@ref). + # Examples ```jldoctest julia> a = zeros(3); diff --git a/base/abstractarraymath.jl b/base/abstractarraymath.jl index 4c4e925bed887..d706896f6bbc5 100644 --- a/base/abstractarraymath.jl +++ b/base/abstractarraymath.jl @@ -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 @@ -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)) @@ -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] @@ -199,6 +203,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) diff --git a/base/array.jl b/base/array.jl index 0ba9d2e2ddc06..e219904fb6101 100644 --- a/base/array.jl +++ b/base/array.jl @@ -1147,6 +1147,8 @@ Remove an item in `collection` and return it. If `collection` is an ordered container, the last item is returned; for unordered containers, an arbitrary element is returned. +See also: [`popat!`](@ref), [`delete!`](@ref), [`splice!`](@ref), [`push!`](@ref). + # Examples ```jldoctest julia> A=[1, 2, 3] @@ -1269,6 +1271,8 @@ Remove the first `item` from `collection`. This function is called `shift` in many other programming languages. +See also: [`pop!`](@ref), [`popat!`](@ref), [`delete!`](@ref). + # Examples ```jldoctest julia> A = [1, 2, 3, 4, 5, 6] @@ -1307,6 +1311,8 @@ end Insert an `item` into `a` at the given `index`. `index` is the index of `item` in the resulting `a`. +See also: [`push!`](@ref), [`replace`](@ref), [`popat!`](@ref), [`splice!`](@ref). + # Examples ```jldoctest julia> insert!([6, 5, 4, 2, 1], 4, 3) @@ -1334,6 +1340,8 @@ end Remove the item at the given `i` and return the modified `a`. Subsequent items are shifted to fill the resulting gap. +See also: [`delete!`](@ref), [`popat!`](@ref), [`splice!`](@ref). + # Examples ```jldoctest julia> deleteat!([6, 5, 4, 3, 2, 1], 2) @@ -1445,6 +1453,8 @@ Subsequent items are shifted left to fill the resulting gap. If specified, replacement values from an ordered collection will be spliced in place of the removed item. +See also: [`replace`](@ref), [`delete!`](@ref), [`deleteat!`](@ref), [`pop!`](@ref), [`popat!`](@ref). + # Examples ```jldoctest julia> A = [6, 5, 4, 3, 2, 1]; splice!(A, 5) @@ -1594,7 +1604,7 @@ end reverse(v [, start=1 [, stop=length(v) ]] ) Return a copy of `v` reversed from start to stop. See also [`Iterators.reverse`](@ref) -for reverse-order iteration without making a copy. +for reverse-order iteration without making a copy, and in-place [`reverse!`](@ref). # Examples ```jldoctest @@ -1797,6 +1807,8 @@ To search for other kinds of values, pass a predicate as the first argument. Indices or keys are of the same type as those returned by [`keys(A)`](@ref) and [`pairs(A)`](@ref). +See also: [`findall`](@ref), [`findnext`](@ref), [`findlast`](@ref), [`searchsortedfirst`](@ref). + # Examples ```jldoctest julia> A = [false, false, true, false] @@ -1938,6 +1950,8 @@ or `nothing` if not found. Indices are of the same type as those returned by [`keys(A)`](@ref) and [`pairs(A)`](@ref). +See also: [`findnext`](@ref), [`findfirst`](@ref), [`findall`](@ref). + # Examples ```jldoctest julia> A = [false, false, true, true] @@ -1983,6 +1997,8 @@ Return `nothing` if there is no `true` value in `A`. Indices or keys are of the same type as those returned by [`keys(A)`](@ref) and [`pairs(A)`](@ref). +See also: [`findfirst`](@ref), [`findprev`](@ref), [`findall`](@ref). + # Examples ```jldoctest julia> A = [true, false, true, false] @@ -2175,6 +2191,8 @@ To search for other kinds of values, pass a predicate as the first argument. Indices or keys are of the same type as those returned by [`keys(A)`](@ref) and [`pairs(A)`](@ref). +See also: [`findfirst`](@ref), [`searchsorted`](@ref). + # Examples ```jldoctest julia> A = [true, false, false, true] @@ -2224,6 +2242,148 @@ findall(x::Bool) = x ? [1] : Vector{Int}() findall(testf::Function, x::Number) = testf(x) ? [1] : Vector{Int}() findall(p::Fix2{typeof(in)}, x::Number) = x in p.x ? [1] : Vector{Int}() +""" + findmax(itr) -> (x, index) + +Return the maximum element of the collection `itr` and its index or key. +If there are multiple maximal elements, then the first one will be returned. +If any data element is `NaN`, this element is returned. +The result is in line with `max`. + +The collection must not be empty. + +See also: [`findmin`](@ref), [`argmax`](@ref), [`maximum`](@ref). + +# Examples +```jldoctest +julia> findmax([8,0.1,-9,pi]) +(8.0, 1) + +julia> findmax([1,7,7,6]) +(7, 2) + +julia> findmax([1,7,7,NaN]) +(NaN, 4) +``` +""" +findmax(a) = _findmax(a, :) + +function _findmax(a, ::Colon) + p = pairs(a) + y = iterate(p) + if y === nothing + throw(ArgumentError("collection must be non-empty")) + end + (mi, m), s = y + i = mi + while true + y = iterate(p, s) + y === nothing && break + m != m && break + (i, ai), s = y + if ai != ai || isless(m, ai) + m = ai + mi = i + end + end + return (m, mi) +end + +""" + findmin(itr) -> (x, index) + +Return the minimum element of the collection `itr` and its index or key. +If there are multiple minimal elements, then the first one will be returned. +If any data element is `NaN`, this element is returned. +The result is in line with `min`. + +The collection must not be empty. + +See also: [`findmax`](@ref), [`argmin`](@ref), [`minimum`](@ref). + +# Examples +```jldoctest +julia> findmin([8,0.1,-9,pi]) +(-9.0, 3) + +julia> findmin([7,1,1,6]) +(1, 2) + +julia> findmin([7,1,1,NaN]) +(NaN, 4) +``` +""" +findmin(a) = _findmin(a, :) + +function _findmin(a, ::Colon) + p = pairs(a) + y = iterate(p) + if y === nothing + throw(ArgumentError("collection must be non-empty")) + end + (mi, m), s = y + i = mi + while true + y = iterate(p, s) + y === nothing && break + m != m && break + (i, ai), s = y + if ai != ai || isless(ai, m) + m = ai + mi = i + end + end + return (m, mi) +end + +""" + argmax(itr) + +Return the index or key of the maximum element in a collection. +If there are multiple maximal elements, then the first one will be returned. + +The collection must not be empty. + +See also: [`argmin`](@ref), [`findmax`](@ref). + +# Examples +```jldoctest +julia> argmax([8,0.1,-9,pi]) +1 + +julia> argmax([1,7,7,6]) +2 + +julia> argmax([1,7,7,NaN]) +4 +``` +""" +argmax(a) = findmax(a)[2] + +""" + argmin(itr) + +Return the index or key of the minimum element in a collection. +If there are multiple minimal elements, then the first one will be returned. + +The collection must not be empty. + +See also: [`argmax`](@ref), [`findmin`](@ref). + +# Examples +```jldoctest +julia> argmin([8,0.1,-9,pi]) +3 + +julia> argmin([7,1,1,6]) +2 + +julia> argmin([7,1,1,NaN]) +4 +``` +""" +argmin(a) = findmin(a)[2] + # similar to Matlab's ismember """ indexin(a, b) @@ -2232,6 +2392,8 @@ Return an array containing the first index in `b` for each value in `a` that is a member of `b`. The output array contains `nothing` wherever `a` is not a member of `b`. +See also: [`sortperm`](@ref), [`findfirst`](@ref). + # Examples ```jldoctest julia> a = ['a', 'b', 'c', 'b', 'd', 'a']; @@ -2365,6 +2527,8 @@ The function `f` is passed one argument. !!! compat "Julia 1.4" Support for `a` as a tuple requires at least Julia 1.4. +See also: [`filter!`](@ref), [`Iterators.filter`](@ref). + # Examples ```jldoctest julia> a = 1:10 diff --git a/base/bool.jl b/base/bool.jl index 92a27543d2fbc..1d59089bc23ac 100644 --- a/base/bool.jl +++ b/base/bool.jl @@ -14,6 +14,8 @@ typemax(::Type{Bool}) = true Boolean not. Implements [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic), returning [`missing`](@ref) if `x` is `missing`. +See also [`~`](@ref) for bitwise not. + # Examples ```jldoctest julia> !true diff --git a/base/complex.jl b/base/complex.jl index 884632d5fc453..c477d8ad9e121 100644 --- a/base/complex.jl +++ b/base/complex.jl @@ -7,6 +7,8 @@ Complex number type with real and imaginary part of type `T`. `ComplexF16`, `ComplexF32` and `ComplexF64` are aliases for `Complex{Float16}`, `Complex{Float32}` and `Complex{Float64}` respectively. + +See also: [`Real`](@ref), [`complex`](@ref), [`real`](@ref). """ struct Complex{T<:Real} <: Number re::T @@ -20,10 +22,15 @@ Complex(x::Real) = Complex(x, zero(x)) The imaginary unit. +See also: [`imag`](@ref), [`angle`](@ref), [`complex`](@ref). + # Examples ```jldoctest julia> im * im -1 + 0im + +julia> (2.0 + 3im)^2 +-5.0 + 12.0im ``` """ const im = Complex(false, true) @@ -54,6 +61,8 @@ float(::Type{Complex{T}}) where {T} = Complex{float(T)} Return the real part of the complex number `z`. +See also: [`imag`](@ref), [`reim`](@ref), [`complex`](@ref), [`isreal`](@ref), [`Real`](@ref). + # Examples ```jldoctest julia> real(1 + 3im) @@ -67,6 +76,8 @@ real(z::Complex) = z.re Return the imaginary part of the complex number `z`. +See also: [`conj`](@ref), [`reim`](@ref), [`adjoint`](@ref), [`angle`](@ref). + # Examples ```jldoctest julia> imag(1 + 3im) @@ -254,6 +265,8 @@ end Compute the complex conjugate of a complex number `z`. +See also: [`angle`](@ref), [`adjoint`](@ref). + # Examples ```jldoctest julia> conj(1 + 3im) @@ -529,6 +542,8 @@ end Return ``\\exp(iz)``. +See also [`cispi`](@ref), [`angle`](@ref). + # Examples ```jldoctest julia> cis(π) ≈ -1 @@ -570,6 +585,8 @@ end Compute the phase angle in radians of a complex number `z`. +See also: [`atan`](@ref), [`cis`](@ref). + # Examples ```jldoctest julia> rad2deg(angle(1 + im)) diff --git a/base/div.jl b/base/div.jl index cff322edc65be..5b29aa05c258a 100644 --- a/base/div.jl +++ b/base/div.jl @@ -75,7 +75,7 @@ rem(x::Integer, y::Integer, r::RoundingMode{:Nearest}) = divrem(x, y, r)[2] Largest integer less than or equal to `x/y`. Equivalent to `div(x, y, RoundDown)`. -See also: [`div`](@ref) +See also: [`div`](@ref), [`cld`](@ref), [`fld1`](@ref). # Examples ```jldoctest @@ -109,7 +109,7 @@ fld(a, b) = div(a, b, RoundDown) Smallest integer larger than or equal to `x/y`. Equivalent to `div(x, y, RoundUp)`. -See also: [`div`](@ref) +See also: [`div`](@ref), [`fld`](@ref). # Examples ```jldoctest @@ -131,6 +131,8 @@ The quotient and remainder from Euclidean division. Equivalent to `(div(x,y,r), rem(x,y,r))`. Equivalently, with the default value of `r`, this call is equivalent to `(x÷y, x%y)`. +See also: [`fldmod`](@ref), [`cld`](@ref). + # Examples ```jldoctest julia> divrem(3,7) @@ -206,6 +208,8 @@ end The floored quotient and modulus after division. A convenience wrapper for `divrem(x, y, RoundDown)`. Equivalent to `(fld(x,y), mod(x,y))`. + +See also: [`fld`](@ref), [`cld`](@ref), [`fldmod1`](@ref). """ fldmod(x,y) = divrem(x, y, RoundDown) diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index 6ea19771da72b..e658cabd69a07 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -931,6 +931,8 @@ kw";" Short-circuiting boolean AND. +See also [`&`](@ref), and the [ternary operator `? :`](@ref kw"?"). + # Examples ```jldoctest julia> x = 3; @@ -949,6 +951,8 @@ kw"&&" Short-circuiting boolean OR. +See also: [`|`](@ref), [`xor`](@ref), [`&&`](@ref). + # Examples ```jldoctest julia> pi < 3 || ℯ < 3 @@ -1164,6 +1168,8 @@ devnull Nothing A type with no fields that is the type of [`nothing`](@ref). + +See also: [`isnothing`](@ref), [`Some`](@ref), [`Missing`](@ref). """ Nothing @@ -1172,6 +1178,8 @@ Nothing The singleton instance of type [`Nothing`](@ref), used by convention when there is no value to return (as in a C `void` function) or when a variable or field holds no value. + +See also: [`isnothing`](@ref), [`something`](@ref), [`missing`](@ref). """ nothing @@ -1714,6 +1722,8 @@ NaN julia> false * NaN 0.0 ``` + +See also: [`digits`](@ref), [`iszero`](@ref), [`NaN`](@ref). """ Bool @@ -1800,6 +1810,8 @@ Symbol(x...) Construct a tuple of the given objects. +See also [`Tuple`](@ref), [`NamedTuple`](@ref). + # Examples ```jldoctest julia> tuple(1, 'b', pi) @@ -1930,7 +1942,9 @@ isdefined """ Vector{T}(undef, n) -Construct an uninitialized [`Vector{T}`](@ref) of length `n`. See [`undef`](@ref). +Construct an uninitialized [`Vector{T}`](@ref) of length `n`. + +See also [`undef`](@ref), [`similar`](@ref). # Examples ```julia-repl @@ -1980,7 +1994,9 @@ Vector{T}(::Missing, n) """ Matrix{T}(undef, m, n) -Construct an uninitialized [`Matrix{T}`](@ref) of size `m`×`n`. See [`undef`](@ref). +Construct an uninitialized [`Matrix{T}`](@ref) of size `m`×`n`. + +See also [`undef`](@ref), [`similar`](@ref). # Examples ```julia-repl @@ -2180,6 +2196,8 @@ julia> +(1, 20, 4) Unary minus operator. +See also: [`abs`](@ref), [`flipsign`](@ref). + # Examples ```jldoctest julia> -1 @@ -2388,6 +2406,8 @@ number of trailing elements. The type `Vararg{T,N}` corresponds to exactly `N` e `Vararg{T}` corresponds to zero or more elements of type `T`. `Vararg` tuple types are used to represent the arguments accepted by varargs methods (see the section on [Varargs Functions](@ref) in the manual.) +See also [`NTuple`](@ref). + # Examples ```jldoctest julia> mytupletype = Tuple{AbstractString, Vararg{Int}} @@ -2420,6 +2440,8 @@ is considered an abstract type, and tuple types are only concrete if their param field names; fields are only accessed by index. See the manual section on [Tuple Types](@ref). + +See also [`Vararg`](@ref), [`NTuple`](@ref), [`tuple`](@ref), [`NamedTuple`](@ref). """ Tuple diff --git a/base/essentials.jl b/base/essentials.jl index bbba482b84974..e3cb442e245d1 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -111,7 +111,7 @@ end Tests whether variable `s` is defined in the current scope. -See also [`isdefined`](@ref). +See also [`isdefined`](@ref), [`isassigned`](@ref). # Examples ```jldoctest @@ -197,6 +197,8 @@ julia> y = convert(Vector{Int}, x); julia> y === x true ``` + +See also: [`round`](@ref), [`trunc`](@ref), [`oftype`](@ref), [`reinterpret`](@ref). """ function convert end @@ -229,6 +231,8 @@ argtail(x, rest...) = rest Return a `Tuple` consisting of all but the first component of `x`. +See also: [`front`](@ref Base.front), [`rest`](@ref Base.rest), [`first`](@ref), [`Iterators.peel`](@ref). + # Examples ```jldoctest julia> Base.tail((1,2,3)) @@ -798,6 +802,8 @@ values(itr) = itr A type with no fields whose singleton instance [`missing`](@ref) is used to represent missing values. + +See also: [`skipmissing`](@ref), [`nonmissingtype`](@ref), [`Nothing`](@ref). """ struct Missing end @@ -805,6 +811,8 @@ struct Missing end missing The singleton instance of type [`Missing`](@ref) representing a missing value. + +See also: [`NaN`](@ref), [`skipmissing`](@ref), [`nonmissingtype`](@ref). """ const missing = Missing() @@ -812,6 +820,8 @@ const missing = Missing() ismissing(x) Indicate whether `x` is [`missing`](@ref). + +See also: [`skipmissing`](@ref), [`isnothing`](@ref), [`isnan`](@ref). """ ismissing(::Any) = false ismissing(::Missing) = true diff --git a/base/file.jl b/base/file.jl index d76e81f62364e..9139b2b97bcd6 100644 --- a/base/file.jl +++ b/base/file.jl @@ -34,6 +34,8 @@ export Get the current working directory. +See also: [`cd`](@ref), [`tempdir`](@ref). + # Examples ```julia-repl julia> pwd() @@ -67,6 +69,8 @@ end Set the current working directory. +See also: [`pwd`](@ref), [`mkdir`](@ref), [`mkpath`](@ref), [`mktempdir`](@ref). + # Examples ```julia-repl julia> cd("/home/JuliaUser/Projects/julia") @@ -662,6 +666,8 @@ the temporary directory is automatically deleted when the process exits. The `cleanup` keyword argument was added in Julia 1.3. Relatedly, starting from 1.3, Julia will remove the temporary paths created by `mktempdir` when the Julia process exits, unless `cleanup` is explicitly set to `false`. + +See also: [`mktemp`](@ref), [`mkdir`](@ref). """ function mktempdir(parent::AbstractString=tempdir(); prefix::AbstractString=temp_prefix, cleanup::Bool=true) @@ -696,6 +702,8 @@ end Apply the function `f` to the result of [`mktemp(parent)`](@ref) and remove the temporary file upon completion. + +See also: [`mktempdir`](@ref). """ function mktemp(fn::Function, parent::AbstractString=tempdir()) (tmp_path, tmp_io) = mktemp(parent, cleanup=false) @@ -719,8 +727,12 @@ end Apply the function `f` to the result of [`mktempdir(parent; prefix)`](@ref) and remove the temporary directory all of its contents upon completion. +<<<<<<< HEAD !!! compat "Julia 1.2" The `prefix` keyword argument was added in Julia 1.2. +======= +See also: [`mktemp`](@ref), [`mkdir`](@ref). +>>>>>>> another batch of see also additions """ function mktempdir(fn::Function, parent::AbstractString=tempdir(); prefix::AbstractString=temp_prefix) diff --git a/base/float.jl b/base/float.jl index 42ec0ad223a74..f5da9380a1588 100644 --- a/base/float.jl +++ b/base/float.jl @@ -37,6 +37,8 @@ const Inf = Inf64 Positive infinity of type [`Float64`](@ref). +See also: [`isfinite`](@ref), [`NaN`](@ref), [`Inf32`](@ref). + # Examples ```jldoctest julia> π/0 @@ -54,6 +56,8 @@ const NaN = NaN64 A not-a-number value of type [`Float64`](@ref). +See also: [`isnan`](@ref), [`missing`](@ref), [`NaN32`](@ref), [`Inf`](@ref). + # Examples ```jldoctest julia> 0/0 @@ -245,6 +249,8 @@ Bool(x::Float16) = x==0 ? false : x==1 ? true : throw(InexactError(:Bool, Bool, Convert a number or array to a floating point data type. +See also: [`complex`](@ref), [`oftype`](@ref), [`convert`](@ref). + # Examples ```jldoctest julia> float(1:1000) diff --git a/base/hashing.jl b/base/hashing.jl index 26b18f11c2fe2..580b27ab86ee0 100644 --- a/base/hashing.jl +++ b/base/hashing.jl @@ -10,10 +10,12 @@ optional second argument `h` is a hash code to be mixed with the result. New types should implement the 2-argument form, typically by calling the 2-argument `hash` method recursively in order to mix hashes of the contents with each other (and with `h`). -Typically, any type that implements `hash` should also implement its own `==` (hence -`isequal`) to guarantee the property mentioned above. Types supporting subtraction +Typically, any type that implements `hash` should also implement its own [`==`](@ref) (hence +[`isequal`](@ref)) to guarantee the property mentioned above. Types supporting subtraction (operator `-`) should also implement [`widen`](@ref), which is required to hash values inside heterogeneous arrays. + +See also: [`objectid`](@ref), [`Dict`](@ref), [`Set`](@ref). """ hash(x::Any) = hash(x, zero(UInt)) hash(w::WeakRef, h::UInt) = hash(w.value, h) diff --git a/base/iddict.jl b/base/iddict.jl index a03edbb60723b..7247a85c9afc8 100644 --- a/base/iddict.jl +++ b/base/iddict.jl @@ -3,7 +3,7 @@ """ IdDict([itr]) -`IdDict{K,V}()` constructs a hash table using object-id as hash and +`IdDict{K,V}()` constructs a hash table using [`objectid`](@ref) as hash and `===` as equality with keys of type `K` and values of type `V`. See [`Dict`](@ref) for further help. In the example below, The `Dict` diff --git a/base/int.jl b/base/int.jl index 2ca38ffef00c8..fd5c2b24606e9 100644 --- a/base/int.jl +++ b/base/int.jl @@ -152,6 +152,8 @@ when `abs` is applied to the minimum representable value of a signed integer. That is, when `x == typemin(typeof(x))`, `abs(x) == x < 0`, not `-x` as might be expected. +See also: [`abs2`](@ref), [`unsigned`](@ref), [`sign`](@ref). + # Examples ```jldoctest julia> abs(-3) @@ -176,12 +178,17 @@ abs(x::Signed) = flipsign(x,x) Convert a number to an unsigned integer. If the argument is signed, it is reinterpreted as unsigned without checking for negative values. + +See also: [`signed`](@ref), [`sign`](@ref), [`signbit`](@ref). + # Examples ```jldoctest julia> unsigned(-2) 0xfffffffffffffffe + julia> unsigned(2) 0x0000000000000002 + julia> signed(unsigned(-2)) -2 ``` @@ -194,6 +201,8 @@ unsigned(x::BitSigned) = reinterpret(typeof(convert(Unsigned, zero(x))), x) Convert a number to a signed integer. If the argument is unsigned, it is reinterpreted as signed without checking for overflow. + +See also: [`unsigned`](@ref), [`sign`](@ref), [`signbit`](@ref). """ signed(x) = x % typeof(convert(Signed, zero(x))) signed(x::BitUnsigned) = reinterpret(typeof(convert(Signed, zero(x))), x) @@ -231,6 +240,8 @@ exceptions, see note below). type, and so rounding error may occur. In particular, if the exact result is very close to `y`, then it may be rounded to `y`. +See also: [`rem`](@ref), [`div`](@ref), [`fld`](@ref), [`mod1`](@ref), [`invmod`](@ref). + ```jldoctest julia> mod(8, 3) 2 @@ -274,6 +285,8 @@ rem(x::T, y::T) where {T<:BitUnsigned64} = checked_urem_int(x, y) Bitwise not. +See also: [`!`](@ref), [`&`](@ref), [`|`](@ref). + # Examples ```jldoctest julia> ~4 @@ -295,6 +308,8 @@ Bitwise and. Implements [three-valued logic](https://en.wikipedia.org/wiki/Three returning [`missing`](@ref) if one operand is `missing` and the other is `true`. Add parentheses for function application form: `(&)(x, y)`. +See also: [`|`](@ref), [`xor`](@ref), [`&&`](@ref). + # Examples ```jldoctest julia> 4 & 10 @@ -318,6 +333,8 @@ false Bitwise or. Implements [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic), returning [`missing`](@ref) if one operand is `missing` and the other is `false`. +See also: [`&`](@ref), [`xor`](@ref), [`||`](@ref). + # Examples ```jldoctest julia> 4 | 10 @@ -500,6 +517,8 @@ A negative value of `k` will rotate to the right instead. !!! compat "Julia 1.5" This function requires Julia 1.5 or later. +See also: [`<<`](@ref), [`circshift`](@ref), [`BitArray`](@ref). + ```jldoctest julia> bitrotate(UInt8(114), 2) 0xc9 @@ -561,7 +580,9 @@ is less than or equal to `x`. `trunc(T, x)` converts the result to type `T`, throwing an `InexactError` if the value is not representable. -`digits`, `sigdigits` and `base` work as for [`round`](@ref). +Keywords `digits`, `sigdigits` and `base` work as for [`round`](@ref). + +See also: [`%`](@ref rem), [`floor`](@ref), [`unsigned`](@ref). """ function trunc end @@ -576,7 +597,7 @@ equal to `x`. `floor(T, x)` converts the result to type `T`, throwing an `InexactError` if the value is not representable. -`digits`, `sigdigits` and `base` work as for [`round`](@ref). +Keywords `digits`, `sigdigits` and `base` work as for [`round`](@ref). """ function floor end @@ -591,7 +612,7 @@ equal to `x`. `ceil(T, x)` converts the result to type `T`, throwing an `InexactError` if the value is not representable. -`digits`, `sigdigits` and `base` work as for [`round`](@ref). +Keywords `digits`, `sigdigits` and `base` work as for [`round`](@ref). """ function ceil end diff --git a/base/irrationals.jl b/base/irrationals.jl index 1f7b1358dd70e..0ef64de333bf7 100644 --- a/base/irrationals.jl +++ b/base/irrationals.jl @@ -22,7 +22,9 @@ abstract type AbstractIrrational <: Real end Irrational{sym} <: AbstractIrrational Number type representing an exact irrational value denoted by the -symbol `sym`. +symbol `sym`, such as [`π`](@ref pi), [`ℯ`](@ref) and [`γ`](@ref Base.MathConstants.eulergamma). + +See also [`@irrational`], [`AbstractIrrational`](@ref). """ struct Irrational{sym} <: AbstractIrrational end diff --git a/base/iterators.jl b/base/iterators.jl index 109e0838710f1..118f19ab845ed 100644 --- a/base/iterators.jl +++ b/base/iterators.jl @@ -288,6 +288,8 @@ the `zip` iterator is a tuple of values of its subiterators. `zip` orders the calls to its subiterators in such a way that stateful iterators will not advance when another iterator finishes in the current iteration. +See also: [`enumerate`](@ref), [`splat`](@ref Base.splat). + # Examples ```jldoctest julia> a = 1:5 @@ -544,6 +546,8 @@ end An iterator that yields the same elements as `iter`, but starting at the given `state`. +See also: [`Iterators.drop`](@ref), [`Iterators.peel`](@ref), [`Base.rest`](@ref). + # Examples ```jldoctest julia> collect(Iterators.rest([1,2,3,4], 2)) @@ -562,6 +566,8 @@ rest(itr) = itr Returns the first element and an iterator over the remaining elements. +See also: [`Iterators.drop`](@ref), [`Iterators.take`](@ref), [`Base.tail`](@ref). + # Examples ```jldoctest julia> (a, rest) = Iterators.peel("abc"); @@ -640,6 +646,8 @@ end An iterator that generates at most the first `n` elements of `iter`. +See also: [`drop`](@ref Iterators.drop), [`peel`](@ref Iterators.peel), [`first`](@ref), [`take!`](@ref). + # Examples ```jldoctest julia> a = 1:2:11 @@ -851,6 +859,8 @@ end An iterator that cycles through `iter` forever. If `iter` is empty, so is `cycle(iter)`. +See also: [`Iterators.repeated`](@ref), [`repeat`](@ref). + # Examples ```jldoctest julia> for (i, v) in enumerate(Iterators.cycle("hello")) @@ -890,6 +900,8 @@ repeated(x) = Repeated(x) An iterator that generates the value `x` forever. If `n` is specified, generates `x` that many times (equivalent to `take(repeated(x), n)`). +See also: [`Iterators.cycle`](@ref), [`repeat`](@ref). + # Examples ```jldoctest julia> a = Iterators.repeated([1 2], 4); @@ -925,6 +937,8 @@ Return an iterator over the product of several iterators. Each generated element a tuple whose `i`th element comes from the `i`th argument iterator. The first iterator changes the fastest. +See also: [`zip`](@ref), [`splat`](@ref Base.splat), [`Iterators.flatten`](@ref). + # Examples ```jldoctest julia> collect(Iterators.product(1:2, 3:5)) diff --git a/base/math.jl b/base/math.jl index a6ff6303fbab4..d63b85279a3d4 100644 --- a/base/math.jl +++ b/base/math.jl @@ -47,6 +47,8 @@ end Return `x` if `lo <= x <= hi`. If `x > hi`, return `hi`. If `x < lo`, return `lo`. Arguments are promoted to a common type. +See also [`clamp!`](@ref), [`trunc`](@ref). + # Examples ```jldoctest julia> clamp.([pi, 1.0, big(10.)], 2., 9.) @@ -205,6 +207,8 @@ end @horner(x, p...) Evaluate `p[1] + x * (p[2] + x * (....))`, i.e. a polynomial via Horner's rule. + +See also [`@evalpoly`](@ref), [`evalpoly`](@ref). """ macro horner(x, p...) xesc, pesc = esc(x), esc.(p) @@ -224,6 +228,8 @@ that is, the coefficients are given in ascending order by power of `z`. This ma to efficient inline code that uses either Horner's method or, for complex `z`, a more efficient Goertzel-like algorithm. +See also [`evalpoly`](@ref). + # Examples ```jldoctest julia> @evalpoly(3, 1, 0, 1) @@ -259,6 +265,8 @@ rad2deg(z::AbstractFloat) = z * (180 / oftype(z, pi)) Convert `x` from degrees to radians. +See also: [`rad2deg`](@ref), [`sind`](@ref). + # Examples ```jldoctest julia> deg2rad(90) @@ -388,6 +396,8 @@ expm1(x::Float32) = ccall((:expm1f,libm), Float32, (Float32,), x) Compute the base 2 exponential of `x`, in other words ``2^x``. +See also [`ldexp`](@ref), [`<<`](@ref). + # Examples ```jldoctest julia> exp2(5) @@ -442,6 +452,8 @@ end sin(x) Compute sine of `x`, where `x` is in radians. + +See also [`sind`], [`sinpi`], [`sincos`], [`cis`]. """ sin(x::Number) @@ -449,6 +461,8 @@ sin(x::Number) cos(x) Compute cosine of `x`, where `x` is in radians. + +See also [`cosd`], [`cospi`], [`sincos`], [`cis`]. """ cos(x::Number) @@ -493,6 +507,8 @@ atanh(x::Number) Compute the natural logarithm of `x`. Throws [`DomainError`](@ref) for negative [`Real`](@ref) arguments. Use complex negative arguments to obtain complex results. +See also [`log1p`], [`log2`], [`log10`]. + # Examples ```jldoctest; filter = r"Stacktrace:(\\n \\[[0-9]+\\].*)*" julia> log(2) @@ -514,6 +530,8 @@ log(x::Number) Compute the logarithm of `x` to base 2. Throws [`DomainError`](@ref) for negative [`Real`](@ref) arguments. +See also: [`exp2`](@ref), [`ldexp`](@ref). + # Examples ```jldoctest; filter = r"Stacktrace:(\\n \\[[0-9]+\\].*)*" julia> log2(4) @@ -598,6 +616,8 @@ end Return ``\\sqrt{x}``. Throws [`DomainError`](@ref) for negative [`Real`](@ref) arguments. Use complex negative arguments instead. The prefix operator `√` is equivalent to `sqrt`. +See also: [`hypot`](@ref). + # Examples ```jldoctest; filter = r"Stacktrace:(\\n \\[[0-9]+\\].*)*" julia> sqrt(big(81)) diff --git a/base/mathconstants.jl b/base/mathconstants.jl index 643e27a364e0c..3c568e27daecb 100644 --- a/base/mathconstants.jl +++ b/base/mathconstants.jl @@ -25,6 +25,8 @@ The constant pi. Unicode `π` can be typed by tab-completing `\\pi` in the Julia REPL. +See also: [`sinpi`](@ref), [`sincospi`](@ref), [`deg2rad`](@ref). + # Examples ```jldoctest julia> pi @@ -44,6 +46,8 @@ The constant ℯ. Unicode `ℯ` can be typed by tab-completing `\\euler` in the Julia REPL. +See also: [`exp`](@ref), [`cis`](@ref), [`cispi`](@ref). + # Examples ```jldoctest julia> ℯ diff --git a/base/missing.jl b/base/missing.jl index 33e8fb3d8d2cc..7e320deab4806 100644 --- a/base/missing.jl +++ b/base/missing.jl @@ -194,6 +194,8 @@ Use [`collect`](@ref) to obtain an `Array` containing the non-`missing` values i be a `Vector` since it is not possible to remove missings while preserving dimensions of the input. +See also [`coalesce`](@ref), [`ismissing`](@ref), [`something`](@ref). + # Examples ```jldoctest julia> x = skipmissing([1, missing, 2]) diff --git a/base/number.jl b/base/number.jl index b2c6df7f7a223..eeb7591b8b2b1 100644 --- a/base/number.jl +++ b/base/number.jl @@ -243,6 +243,8 @@ inv(x::Number) = one(x)/x Multiply `x` and `y`, giving the result as a larger type. +See also [`promote`](@ref), [`Base.add_sum`](@ref). + # Examples ```jldoctest julia> widemul(Float32(3.0), 4.0) isa BigFloat @@ -309,6 +311,8 @@ should return an identity value of the same precision If you want a quantity that is of the same type as `x`, or of type `T`, even if `x` is dimensionful, use [`oneunit`](@ref) instead. +See also [`identity`](@ref), [`LinearAlgebra.I`](@ref). + # Examples ```jldoctest julia> one(3.7) diff --git a/base/operators.jl b/base/operators.jl index 9882e50264267..669d136d40b13 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -561,6 +561,8 @@ extrema(f, x::Real) = (y = f(x); (y, y)) The identity function. Returns its argument. +See also: [`one`](@ref), [`oneunit`](@ref), [`I`](@ref LinearAlgebra.I). + # Examples ```jldoctest julia> identity("Well, what did you expect?") @@ -764,6 +766,8 @@ end Remainder from Euclidean division, returning a value of the same sign as `x`, and smaller in magnitude than `y`. This value is always exact. +See also: [`div`](@ref), [`mod`](@ref), [`mod1`](@ref), [`divrem`](@ref). + # Examples ```jldoctest julia> x = 15; y = 4; @@ -788,6 +792,8 @@ const % = rem The quotient from Euclidean division. Computes `x/y`, truncated to an integer. +See also: [`cld`](@ref), [`fld`](@ref), [`rem`](@ref), [`divrem`](@ref). + # Examples ```jldoctest julia> 9 ÷ 4 @@ -939,7 +945,7 @@ julia> fs = [ julia> ∘(fs...)(3) 3.0 ``` -See also [`ComposedFunction`](@ref). +See also [`ComposedFunction`](@ref), [`!`](@ref). """ function ∘ end @@ -999,6 +1005,8 @@ end Predicate function negation: when the argument of `!` is a function, it returns a function which computes the boolean negation of `f`. +See also [`∘`](@ref). + # Examples ```jldoctest julia> str = "∀ ε > 0, ∃ δ > 0: |x-y| < δ ⇒ |f(x)-f(y)| < ε" @@ -1019,6 +1027,8 @@ julia> filter(!isletter, str) A type representing a partially-applied version of the two-argument function `f`, with the first argument fixed to the value "x". In other words, `Fix1(f, x)` behaves similarly to `y->f(x, y)`. + +See also [`Fix2`](@ref Base.Fix2). """ struct Fix1{F,T} <: Function f::F @@ -1276,6 +1286,8 @@ julia> [1, 2] .∈ ([2, 3],) 0 1 ``` + +See also: [`insorted`](@ref), [`contains`](@ref), [`occursin`](@ref), [issubset](@ref). """ in diff --git a/base/promotion.jl b/base/promotion.jl index c7abacf68db4a..67166a3952ea6 100644 --- a/base/promotion.jl +++ b/base/promotion.jl @@ -5,7 +5,6 @@ """ typejoin(T, S) - Return the closest common ancestor of `T` and `S`, i.e. the narrowest type from which they both inherit. """ @@ -145,6 +144,8 @@ Compute a type that contains both `T` and `S`, which could be either a parent of both types, or a `Union` if appropriate. Falls back to [`typejoin`](@ref). +See also: [`promote`](@ref), [`promote_type`](@ref). + # Examples ```jldoctest julia> Base.promote_typejoin(Int, Float64) @@ -200,6 +201,9 @@ tolerated; for example, `promote_type(Int64, Float64)` returns [`Float64`](@ref) even though strictly, not all [`Int64`](@ref) values can be represented exactly as `Float64` values. +See also: [`promote`](@ref), [`promote_typejoin`](@ref), [`promote_rule`](@ref). + +# Examples ```jldoctest julia> promote_type(Int64, Float64) Float64 @@ -263,6 +267,8 @@ promote_result(::Type{T},::Type{S},::Type{Bottom},::Type{Bottom}) where {T,S} = Convert all arguments to a common type, and return them all (as a tuple). If no arguments can be converted, an error is raised. +See also: [`promote_type`], [`promote_rule`]. + # Examples ```jldoctest julia> promote(Int8(1), Float16(4.5), Float32(4.1)) diff --git a/base/reduce.jl b/base/reduce.jl index a3c8099b979a5..4efd636bf4eb2 100644 --- a/base/reduce.jl +++ b/base/reduce.jl @@ -516,6 +516,8 @@ for non-empty collections. !!! compat "Julia 1.6" Keyword argument `init` requires Julia 1.6 or later. +See also: [`reduce`](@ref), [`mapreduce`](@ref), [`count`](@ref), [`union`](@ref). + # Examples ```jldoctest julia> sum(1:20) @@ -570,6 +572,8 @@ for non-empty collections. !!! compat "Julia 1.6" Keyword argument `init` requires Julia 1.6 or later. +See also: [`reduce`](@ref), [`cumprod`](@ref), [`any`](@ref). + # Examples ```jldoctest julia> prod(1:5) @@ -989,6 +993,8 @@ If the input contains [`missing`](@ref) values, return `missing` if all non-miss values are `false` (or equivalently, if the input contains no `true` value), following [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic). +See also: [`all`](@ref), [`count`](@ref), [`sum`](@ref), [`|`](@ref), , [`||`](@ref). + # Examples ```jldoctest julia> a = [true,false,false,true] @@ -1024,6 +1030,8 @@ If the input contains [`missing`](@ref) values, return `missing` if all non-miss values are `true` (or equivalently, if the input contains no `false` value), following [three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic). +See also: [`all!`](@ref), [`any`](@ref), [`count`](@ref), [`&`](@ref), , [`&&`](@ref), [`allunique`](@ref). + # Examples ```jldoctest julia> a = [true,false,false,true] @@ -1163,6 +1171,8 @@ to start counting from and therefore also determines the output type. !!! compat "Julia 1.6" `init` keyword was added in Julia 1.6. +See also: [`any`](@ref), [`sum`](@ref). + # Examples ```jldoctest julia> count(i->(4<=i<=6), [2,3,4,5,6]) diff --git a/base/reducedim.jl b/base/reducedim.jl index 855a5be6c48bf..f10aaf6f4d8f3 100644 --- a/base/reducedim.jl +++ b/base/reducedim.jl @@ -667,6 +667,8 @@ Compute the minimum value of an array over the given dimensions. See also the [`min(a,b)`](@ref) function to take the minimum of two or more arguments, which can be applied elementwise to arrays via `min.(a,b)`. +See also: [`minimum!`](@ref), [`extrema`](@ref), [`findmin`](@ref), [`argmin`](@ref). + # Examples ```jldoctest julia> A = [1 2; 3 4] diff --git a/base/reflection.jl b/base/reflection.jl index fff6abafa62ae..67f56c907feab 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -20,6 +20,8 @@ nameof(m::Module) = ccall(:jl_module_name, Ref{Symbol}, (Any,), m) Get a module's enclosing `Module`. `Main` is its own parent. +See also: [`names`](@ref), [`nameof`](@ref), [`fullname`](@ref), [`@__MODULE__`](@ref). + # Examples ```jldoctest julia> parentmodule(Main) @@ -94,6 +96,8 @@ are also included. As a special case, all names defined in `Main` are considered \"exported\", since it is not idiomatic to explicitly export names from `Main`. + +See also: [`@locals`](@ref Base.@locals), [`@__MODULE__`](@ref). """ names(m::Module; all::Bool = false, imported::Bool = false) = sort!(ccall(:jl_module_names, Array{Symbol,1}, (Any, Cint, Cint), m, all, imported)) @@ -167,6 +171,8 @@ fieldname(t::Type{<:Tuple}, i::Integer) = Get a tuple with the names of the fields of a `DataType`. +See also [`propertynames`](@ref), [`hasfield`](@ref). + # Examples ```jldoctest julia> fieldnames(Rational) @@ -290,6 +296,8 @@ end objectid(x) Get a hash value for `x` based on object identity. `objectid(x)==objectid(y)` if `x === y`. + +See also [`hash`](@ref), [`IdDict`](@ref). """ objectid(@nospecialize(x)) = ccall(:jl_object_id, UInt, (Any,), x) @@ -507,6 +515,8 @@ This category of types is significant since they are valid as type parameters, may not track [`isdefined`](@ref) / [`isassigned`](@ref) status, and have a defined layout that is compatible with C. +See also [`isbits`](@ref), [`isprimitivetype`](@ref), [`ismutable`](@ref). + # Examples ```jldoctest julia> isbitstype(Complex{Float64}) @@ -552,6 +562,8 @@ end Determine whether type `T` is a concrete type, meaning it could have direct instances (values `x` such that `typeof(x) === T`). +See also: [`isbits`](@ref), [`isabstracttype`](@ref), [`issingletontype`](@ref). + # Examples ```jldoctest julia> isconcretetype(Complex) @@ -907,6 +919,8 @@ A list of modules can also be specified as an array. !!! compat "Julia 1.4" At least Julia 1.4 is required for specifying a module. + +See also: [`which`](@ref), [`@which`](@ref). """ function methods(@nospecialize(f), @nospecialize(t), mod::Union{Tuple{Module},AbstractArray{Module},Nothing}=nothing) @@ -1236,6 +1250,8 @@ print_statement_costs(args...; kwargs...) = print_statement_costs(stdout, args.. Returns the method of `f` (a `Method` object) that would be called for arguments of the given `types`. If `types` is an abstract type, then the method that would be called by `invoke` is returned. + +See also: [`@which`](@ref), [`@edit`](@ref), [`parentmodule`](@ref). """ function which(@nospecialize(f), @nospecialize(t)) if isa(f, Core.Builtin) @@ -1583,6 +1599,8 @@ as well to get the properties of an instance of the type. of the documented interface of `x`. If you want it to also return "private" fieldnames intended for internal use, pass `true` for the optional second argument. REPL tab completion on `x.` shows only the `private=false` properties. + +See also: [`hasproperty`](@ref), [`hasfield`](@ref). """ propertynames(x) = fieldnames(typeof(x)) propertynames(m::Module) = names(m) @@ -1595,5 +1613,7 @@ Return a boolean indicating whether the object `x` has `s` as one of its own pro !!! compat "Julia 1.2" This function requires at least Julia 1.2. + +See also: [`propertynames`](@ref), [`hasfield`](@ref). """ hasproperty(x, s::Symbol) = s in propertynames(x) diff --git a/base/set.jl b/base/set.jl index 4f16825a3de89..0c8a8b95b10ce 100644 --- a/base/set.jl +++ b/base/set.jl @@ -17,6 +17,8 @@ Set() = Set{Any}() Construct a [`Set`](@ref) of the values generated by the given iterable object, or an empty set. Should be used instead of [`BitSet`](@ref) for sparse integer sets, or for sets of arbitrary objects. + +See also: [`push!`](@ref), [`empty!`](@ref), [`union!`](@ref), [`in`](@ref). """ Set(itr) = _Set(itr, IteratorEltype(itr)) @@ -105,6 +107,8 @@ as determined by [`isequal`](@ref), in the order that the first of each set of equivalent elements originally appears. The element type of the input is preserved. +See also: [`unique!`](@ref), [`allunique`](@ref). + # Examples ```jldoctest julia> unique([1, 2, 6, 2]) @@ -371,6 +375,8 @@ end Return `true` if all values from `itr` are distinct when compared with [`isequal`](@ref). +See also: [`unique`](@ref), [`issorted`](@ref). + # Examples ```jldoctest julia> a = [1; 2; 3] diff --git a/base/some.jl b/base/some.jl index 19289a4408da5..7183775a8fc0e 100644 --- a/base/some.jl +++ b/base/some.jl @@ -62,6 +62,8 @@ Return `true` if `x === nothing`, and return `false` if not. !!! compat "Julia 1.1" This function requires at least Julia 1.1. + +See also [`something`](@ref), [`notnothing`](@ref), [`ismissing`](@ref). """ isnothing(::Any) = false isnothing(::Nothing) = true diff --git a/base/sort.jl b/base/sort.jl index e92441b2c99b8..27075e4a97164 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -337,6 +337,8 @@ according to the order specified by the `by`, `lt` and `rev` keywords, assuming is already sorted in that order. Return an empty range located at the insertion point if `a` does not contain values equal to `x`. +See also: [`insorted`](@ref), [`searchsortedfirst`](@ref), [`sort`](@ref), [`findall`](@ref). + # Examples ```jldoctest julia> searchsorted([1, 2, 4, 5, 5, 7], 4) # single match @@ -363,6 +365,8 @@ Return the index of the first value in `a` greater than or equal to `x`, accordi specified order. Return `length(a) + 1` if `x` is greater than all values in `a`. `a` is assumed to be sorted. +See also: [`searchsortedlast`](@ref), [`searchsorted`](@ref), [`findfirst`](@ref). + # Examples ```jldoctest julia> searchsortedfirst([1, 2, 4, 5, 5, 7], 4) # single match diff --git a/base/special/trig.jl b/base/special/trig.jl index 84a2ea51ca013..33643c5bd0d5a 100644 --- a/base/special/trig.jl +++ b/base/special/trig.jl @@ -168,6 +168,8 @@ end Simultaneously compute the sine and cosine of `x`, where `x` is in radians, returning a tuple `(sine, cosine)`. + +See also [`cis`](@ref), [`sincospi`](@ref), [`sincosd`](@ref). """ function sincos(x::T) where T<:Union{Float32, Float64} if abs(x) < T(pi)/4 @@ -742,6 +744,8 @@ mulpi_ext(x::Real) = pi*x # Fallback sinpi(x) Compute ``\\sin(\\pi x)`` more accurately than `sin(pi*x)`, especially for large `x`. + +See also [`sind`](@ref), [`cospi`](@ref), [`sincospi`](@ref). """ function sinpi(x::T) where T<:AbstractFloat if !isfinite(x) @@ -863,6 +867,8 @@ where `x` is in radians), returning a tuple `(sine, cosine)`. !!! compat "Julia 1.6" This function requires Julia 1.6 or later. + +See also: [`cispi`](@ref), [`sincosd`](@ref), [`sinpi`](@ref). """ function sincospi(x::T) where T<:AbstractFloat if !isfinite(x) @@ -1069,6 +1075,8 @@ isinf_real(x::Number) = false sinc(x) Compute ``\\sin(\\pi x) / (\\pi x)`` if ``x \\neq 0``, and ``1`` if ``x = 0``. + +See also [`cosc`](@ref), its derivative. """ sinc(x::Number) = _sinc(float(x)) sinc(x::Integer) = iszero(x) ? one(x) : zero(x) diff --git a/base/strings/io.jl b/base/strings/io.jl index dda567414f073..6288314b2d510 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -57,6 +57,8 @@ end Print (using [`print`](@ref)) `xs` followed by a newline. If `io` is not supplied, prints to [`stdout`](@ref). +See also: [`show`](@ref), [`@show`](@ref), [`@info`](@ref Logging.@logmsg), [`sprint`](@ref), [`Printf.@printf`](@ref). + # Examples ```jldoctest julia> println("Hello, world") @@ -165,6 +167,8 @@ highly efficient, then it may make sense to add a method to `string` and define `print(io::IO, x::MyType) = print(io, string(x))` to ensure the functions are consistent. +See also: [`String`](@ref), [`repr`](@ref), [`sprint`](@ref), [`show`](@ref @show). + # Examples ```jldoctest julia> string("a", 1, true) diff --git a/base/strings/util.jl b/base/strings/util.jl index 04c4f3c4089d2..190c600febc6a 100644 --- a/base/strings/util.jl +++ b/base/strings/util.jl @@ -77,6 +77,8 @@ Return `true` if `haystack` contains `needle`. This is the same as `occursin(needle, haystack)`, but is provided for consistency with `startswith(haystack, needle)` and `endswith(haystack, needle)`. +See also [`occursin`](@ref), [`in`](@ref), [`issubset`](@ref). + # Examples ```jldoctest julia> contains("JuliaLang is pretty cool!", "Julia") @@ -166,6 +168,8 @@ The call `chop(s)` removes the last character from `s`. If it is requested to remove more characters than `length(s)` then an empty string is returned. +See also [`chomp`](@ref), [`startswith`](@ref), [`first`](@ref). + # Examples ```jldoctest julia> a = "March" @@ -196,6 +200,8 @@ end Remove a single trailing newline from a string. +See also [`chop`](@ref). + # Examples ```jldoctest julia> chomp("Hello\\n") diff --git a/base/threadingconstructs.jl b/base/threadingconstructs.jl index 27096e1ba8be6..6c7a8ef2410cd 100644 --- a/base/threadingconstructs.jl +++ b/base/threadingconstructs.jl @@ -15,6 +15,8 @@ threadid() = Int(ccall(:jl_threadid, Int16, ())+1) Get the number of threads available to the Julia process. This is the inclusive upper bound on [`threadid()`](@ref). + +See also: [`BLAS.get_num_threads`](@ref LinearAlgebra.BLAS.get_num_threads), [`BLAS.set_num_threads`](@ref LinearAlgebra.BLAS.set_num_threads), [`Distributed.addprocs`](@ref). """ nthreads() = Int(unsafe_load(cglobal(:jl_n_threads, Cint))) @@ -114,6 +116,8 @@ The default schedule (used when no `schedule` argument is present) is subject to !!! compat "Julia 1.5" The `schedule` argument is available as of Julia 1.5. + +See also: [`@spawn`](@ref Threads.@spawn), [`nthreads()`](@ref Threads.nthreads), [`threadid()`](@ref Threads.threadid), [Distributed.pmap](@ref), [`BLAS.set_num_threads`](@ref LinearAlgebra.BLAS.set_num_threads). """ macro threads(args...) na = length(args) diff --git a/base/tuple.jl b/base/tuple.jl index d0b849f3a9803..48a03dcf0bc0b 100644 --- a/base/tuple.jl +++ b/base/tuple.jl @@ -110,6 +110,8 @@ in assignments, like `a, b... = collection`. !!! compat "Julia 1.6" `Base.rest` requires at least Julia 1.6. +See also: [`first`](@ref first), [`tail`](@ref Base.tail), [`Iterators.rest`](@ref). + # Examples ```jldoctest julia> a = [1 2; 3 4] @@ -186,6 +188,8 @@ safe_tail(t::Tuple{}) = () Return a `Tuple` consisting of all but the last component of `x`. +See also: [`first`](@ref), [`tail`](@ref Base.tail). + # Examples ```jldoctest julia> Base.front((1,2,3)) diff --git a/stdlib/InteractiveUtils/src/InteractiveUtils.jl b/stdlib/InteractiveUtils/src/InteractiveUtils.jl index 94e2222a2355f..f52d3e3deb80c 100644 --- a/stdlib/InteractiveUtils/src/InteractiveUtils.jl +++ b/stdlib/InteractiveUtils/src/InteractiveUtils.jl @@ -81,6 +81,8 @@ Print information about the version of Julia in use. The output is controlled with boolean keyword arguments: - `verbose`: print all additional information + +See also: [`VERSION`](@ref). """ function versioninfo(io::IO=stdout; verbose::Bool=false) println(io, "Julia Version $VERSION") @@ -261,6 +263,8 @@ subtypes(m::Module, x::Type) = _subtypes_in([m], x) Return a list of immediate subtypes of DataType `T`. Note that all currently loaded subtypes are included, including those not visible in the current module. +See also [`supertype`](@ref), [`supertypes`](@ref), [`methodswith`](@ref). + # Examples ```jldoctest julia> subtypes(Integer) @@ -279,6 +283,8 @@ Return a tuple `(T, ..., Any)` of `T` and all its supertypes, as determined by successive calls to the [`supertype`](@ref) function, listed in order of `<:` and terminated by `Any`. +See also [`subtypes`](@ref). + # Examples ```jldoctest julia> supertypes(Int) diff --git a/stdlib/InteractiveUtils/src/macros.jl b/stdlib/InteractiveUtils/src/macros.jl index dd637c8169b87..20904a3620a33 100644 --- a/stdlib/InteractiveUtils/src/macros.jl +++ b/stdlib/InteractiveUtils/src/macros.jl @@ -247,7 +247,9 @@ It calls out to the `functionloc` function. Applied to a function or macro call, it evaluates the arguments to the specified call, and returns the `Method` object for the method that would be called for those arguments. Applied to a variable, it returns the module in which the variable was bound. It calls out to the -`which` function. +[`which`](@ref) function. + +See also: [`@less`](@ref), [`@edit`](@ref). """ :@which @@ -256,6 +258,8 @@ to a variable, it returns the module in which the variable was bound. It calls o Evaluates the arguments to the function or macro call, determines their types, and calls the `less` function on the resulting expression. + +See also: [`@edit`](@ref), [`@which`](@ref), [`@code_lowered`](@ref). """ :@less @@ -264,6 +268,8 @@ function on the resulting expression. Evaluates the arguments to the function or macro call, determines their types, and calls the `edit` function on the resulting expression. + +See also: [`@less`](@ref), [`@which`](@ref). """ :@edit diff --git a/stdlib/LinearAlgebra/src/generic.jl b/stdlib/LinearAlgebra/src/generic.jl index 21b011756aa0e..311bd191c7cb6 100644 --- a/stdlib/LinearAlgebra/src/generic.jl +++ b/stdlib/LinearAlgebra/src/generic.jl @@ -1106,6 +1106,8 @@ When `A` is sparse, a similar polyalgorithm is used. For indefinite matrices, th factorization does not use pivoting during the numerical factorization and therefore the procedure can fail even for invertible matrices. +See also: [`factorize`](@ref), [`pinv`](@ref). + # Examples ```jldoctest julia> A = [1 0; 1 -2]; B = [32; -4]; From 69eb2bb3a6ac909a31fc1c019d1fc6ca5b739b91 Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Thu, 10 Dec 2020 17:52:02 +0100 Subject: [PATCH 10/28] add some functions to docs --- doc/src/base/arrays.md | 1 + doc/src/base/base.md | 5 +++++ doc/src/base/math.md | 1 + 3 files changed, 7 insertions(+) diff --git a/doc/src/base/arrays.md b/doc/src/base/arrays.md index ec8678361da60..4c8e08c402621 100644 --- a/doc/src/base/arrays.md +++ b/doc/src/base/arrays.md @@ -91,6 +91,7 @@ Base.Broadcast.result_style Base.getindex(::AbstractArray, ::Any...) Base.setindex!(::AbstractArray, ::Any, ::Any...) Base.copyto!(::AbstractArray, ::CartesianIndices, ::AbstractArray, ::CartesianIndices) +Base.copy! Base.isassigned Base.Colon Base.CartesianIndex diff --git a/doc/src/base/base.md b/doc/src/base/base.md index 47d581ba76ce6..2f8d931001004 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -30,7 +30,10 @@ Base.MainInclude.include Base.include_string Base.include_dependency Base.which(::Any, ::Any) +Base.@which Base.methods +Base.@less +Base.@edit Base.@show ans Base.active_project @@ -156,6 +159,7 @@ Base.typejoin Base.typeintersect Base.promote_type Base.promote_rule +Base.promote_typejoin Base.isdispatchtuple ``` @@ -211,6 +215,7 @@ Core.Union Union{} Core.UnionAll Core.Tuple +Core.NTuple Core.NamedTuple Base.@NamedTuple Base.Val diff --git a/doc/src/base/math.md b/doc/src/base/math.md index e0f094572a398..f567db09844da 100644 --- a/doc/src/base/math.md +++ b/doc/src/base/math.md @@ -65,6 +65,7 @@ Base.tan(::Number) Base.Math.sind Base.Math.cosd Base.Math.tand +Base.Math.sincosd Base.Math.sinpi Base.Math.cospi Base.Math.sincospi From 69e8c329f3ad781d9598b6b872517df81de56468 Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Mon, 14 Dec 2020 00:30:20 +0100 Subject: [PATCH 11/28] some fixes? --- base/abstractset.jl | 2 +- base/docs/basedocs.jl | 2 +- base/iterators.jl | 2 +- base/number.jl | 2 +- base/operators.jl | 2 +- base/reflection.jl | 4 ++-- base/show.jl | 2 +- base/strings/io.jl | 2 +- base/threadingconstructs.jl | 4 ++-- doc/src/base/base.md | 2 ++ doc/src/base/math.md | 1 + stdlib/LinearAlgebra/docs/src/index.md | 1 + 12 files changed, 15 insertions(+), 11 deletions(-) diff --git a/base/abstractset.jl b/base/abstractset.jl index 81db69d8940d3..61d497c99c8f9 100644 --- a/base/abstractset.jl +++ b/base/abstractset.jl @@ -103,7 +103,7 @@ end Construct the intersection of sets. Maintain order with arrays. -See also: [`setdiff`](@ref), [`isdisjoint`](@ref), [`issubset`](@ref), [`issetequal`](@ref). +See also: [`setdiff`](@ref), [`isdisjoint`](@ref), [`issubset`](@ref Base.issubset), [`issetequal`](@ref). # Examples ```jldoctest diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index e658cabd69a07..0109cf3bb15bd 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -931,7 +931,7 @@ kw";" Short-circuiting boolean AND. -See also [`&`](@ref), and the [ternary operator `? :`](@ref kw"?"). +See also [`&`](@ref), the ternary operator `? :`, and the manual section on [control flow](@ref man-conditional-evaluation). # Examples ```jldoctest diff --git a/base/iterators.jl b/base/iterators.jl index 118f19ab845ed..c5c01ab8906c9 100644 --- a/base/iterators.jl +++ b/base/iterators.jl @@ -937,7 +937,7 @@ Return an iterator over the product of several iterators. Each generated element a tuple whose `i`th element comes from the `i`th argument iterator. The first iterator changes the fastest. -See also: [`zip`](@ref), [`splat`](@ref Base.splat), [`Iterators.flatten`](@ref). +See also: [`zip`](@ref), [`Iterators.flatten`](@ref), `Base.splat`. # Examples ```jldoctest diff --git a/base/number.jl b/base/number.jl index eeb7591b8b2b1..d091126f69fe6 100644 --- a/base/number.jl +++ b/base/number.jl @@ -311,7 +311,7 @@ should return an identity value of the same precision If you want a quantity that is of the same type as `x`, or of type `T`, even if `x` is dimensionful, use [`oneunit`](@ref) instead. -See also [`identity`](@ref), [`LinearAlgebra.I`](@ref). +See also [`identity`](@ref), `LinearAlgebra.I`. # Examples ```jldoctest diff --git a/base/operators.jl b/base/operators.jl index 669d136d40b13..143214f3449df 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -561,7 +561,7 @@ extrema(f, x::Real) = (y = f(x); (y, y)) The identity function. Returns its argument. -See also: [`one`](@ref), [`oneunit`](@ref), [`I`](@ref LinearAlgebra.I). +See also: [`one`](@ref), [`oneunit`](@ref), `LinearAlgebra.I`. # Examples ```jldoctest diff --git a/base/reflection.jl b/base/reflection.jl index 67f56c907feab..88f9813c55575 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -920,7 +920,7 @@ A list of modules can also be specified as an array. !!! compat "Julia 1.4" At least Julia 1.4 is required for specifying a module. -See also: [`which`](@ref), [`@which`](@ref). +See also: [`which`](@ref), [`@which`](@ref Base.@which). """ function methods(@nospecialize(f), @nospecialize(t), mod::Union{Tuple{Module},AbstractArray{Module},Nothing}=nothing) @@ -1251,7 +1251,7 @@ Returns the method of `f` (a `Method` object) that would be called for arguments If `types` is an abstract type, then the method that would be called by `invoke` is returned. -See also: [`@which`](@ref), [`@edit`](@ref), [`parentmodule`](@ref). +See also: [`@which`](@ref Base.@which), [`@edit`](@ref Base.@edit), [`parentmodule`](@ref). """ function which(@nospecialize(f), @nospecialize(t)) if isa(f, Core.Builtin) diff --git a/base/show.jl b/base/show.jl index 9ecb3c5d09073..0bc85c6550cbf 100644 --- a/base/show.jl +++ b/base/show.jl @@ -898,7 +898,7 @@ show_supertypes(typ::DataType) = show_supertypes(stdout, typ) Prints one or more expressions, and their results, to `stdout`, and returns the last result. -See also: [`show`](@ref), [`@info`](@ref Logging.@logmsg), [`println`](@ref). +See also: [`show`](@ref), [`@info`](@ref Logging), [`println`](@ref). # Examples ```jldoctest diff --git a/base/strings/io.jl b/base/strings/io.jl index 6288314b2d510..fc960452e7592 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -57,7 +57,7 @@ end Print (using [`print`](@ref)) `xs` followed by a newline. If `io` is not supplied, prints to [`stdout`](@ref). -See also: [`show`](@ref), [`@show`](@ref), [`@info`](@ref Logging.@logmsg), [`sprint`](@ref), [`Printf.@printf`](@ref). +See also: [`show`](@ref), [`@show`](@ref), [`@info`](@ref Logging), [`sprint`](@ref), [`Printf.@printf`](@ref Printf). # Examples ```jldoctest diff --git a/base/threadingconstructs.jl b/base/threadingconstructs.jl index 6c7a8ef2410cd..b0b7037c4c3a5 100644 --- a/base/threadingconstructs.jl +++ b/base/threadingconstructs.jl @@ -16,7 +16,7 @@ threadid() = Int(ccall(:jl_threadid, Int16, ())+1) Get the number of threads available to the Julia process. This is the inclusive upper bound on [`threadid()`](@ref). -See also: [`BLAS.get_num_threads`](@ref LinearAlgebra.BLAS.get_num_threads), [`BLAS.set_num_threads`](@ref LinearAlgebra.BLAS.set_num_threads), [`Distributed.addprocs`](@ref). +See also: `BLAS.get_num_threads` and `BLAS.set_num_threads` in the [`LinearAlgebra`](@ref man-linalg) standard library. """ nthreads() = Int(unsafe_load(cglobal(:jl_n_threads, Cint))) @@ -117,7 +117,7 @@ The default schedule (used when no `schedule` argument is present) is subject to !!! compat "Julia 1.5" The `schedule` argument is available as of Julia 1.5. -See also: [`@spawn`](@ref Threads.@spawn), [`nthreads()`](@ref Threads.nthreads), [`threadid()`](@ref Threads.threadid), [Distributed.pmap](@ref), [`BLAS.set_num_threads`](@ref LinearAlgebra.BLAS.set_num_threads). +See also: [`@spawn`](@ref Threads.@spawn), [`nthreads()`](@ref Threads.nthreads), [`threadid()`](@ref Threads.threadid), [Distributed.pmap](@ref Distributed), `BLAS.set_num_threads` in [`LinearAlgebra`](@ref). """ macro threads(args...) na = length(args) diff --git a/doc/src/base/base.md b/doc/src/base/base.md index 2f8d931001004..a54d051b1016b 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -222,6 +222,7 @@ Base.Val Core.Vararg Core.Nothing Base.isnothing +Base.notnothing Base.Some Base.something Base.Enums.Enum @@ -405,6 +406,7 @@ Base.isconst Base.nameof(::Function) Base.functionloc(::Any, ::Any) Base.functionloc(::Method) +Base.@locals ``` ## Internals diff --git a/doc/src/base/math.md b/doc/src/base/math.md index f567db09844da..1c90d75f9fb62 100644 --- a/doc/src/base/math.md +++ b/doc/src/base/math.md @@ -176,6 +176,7 @@ Base.nextprod Base.invmod Base.powermod Base.ndigits +Base.add_sum Base.widemul Base.Math.evalpoly Base.Math.@evalpoly diff --git a/stdlib/LinearAlgebra/docs/src/index.md b/stdlib/LinearAlgebra/docs/src/index.md index 52e7860999287..1c152bb8a3b35 100644 --- a/stdlib/LinearAlgebra/docs/src/index.md +++ b/stdlib/LinearAlgebra/docs/src/index.md @@ -576,6 +576,7 @@ LinearAlgebra.BLAS.trmv LinearAlgebra.BLAS.trsv! LinearAlgebra.BLAS.trsv LinearAlgebra.BLAS.set_num_threads +LinearAlgebra.BLAS.get_num_threads ``` ## LAPACK functions From e0c7621f4e5212a6350ec34035c699ef5166a8ec Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Tue, 22 Dec 2020 02:12:17 +0100 Subject: [PATCH 12/28] fix some bugs --- base/number.jl | 3 ++- base/operators.jl | 4 ++-- base/reflection.jl | 4 ++-- base/strings/io.jl | 2 +- base/threadingconstructs.jl | 2 +- doc/src/base/base.md | 4 +--- stdlib/InteractiveUtils/docs/src/index.md | 2 +- stdlib/Printf/docs/src/index.md | 2 +- 8 files changed, 11 insertions(+), 12 deletions(-) diff --git a/base/number.jl b/base/number.jl index d091126f69fe6..ce5f988cf2365 100644 --- a/base/number.jl +++ b/base/number.jl @@ -311,7 +311,8 @@ should return an identity value of the same precision If you want a quantity that is of the same type as `x`, or of type `T`, even if `x` is dimensionful, use [`oneunit`](@ref) instead. -See also [`identity`](@ref), `LinearAlgebra.I`. +See also the [`identity`](@ref) function, +and `I` in [`LinearAlgebra`](@ref man-linalg) for the identity matrix. # Examples ```jldoctest diff --git a/base/operators.jl b/base/operators.jl index 143214f3449df..e7ca6de8a569e 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -561,7 +561,7 @@ extrema(f, x::Real) = (y = f(x); (y, y)) The identity function. Returns its argument. -See also: [`one`](@ref), [`oneunit`](@ref), `LinearAlgebra.I`. +See also: [`one`](@ref), [`oneunit`](@ref), and [`LinearAlgebra`](@ref man-linalg)'s `I`. # Examples ```jldoctest @@ -1287,7 +1287,7 @@ julia> [1, 2] .∈ ([2, 3],) 1 ``` -See also: [`insorted`](@ref), [`contains`](@ref), [`occursin`](@ref), [issubset](@ref). +See also: [`insorted`](@ref), [`contains`](@ref), [`occursin`](@ref), [`issubset`](@ref). """ in diff --git a/base/reflection.jl b/base/reflection.jl index 88f9813c55575..a9f8993be8312 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -920,7 +920,7 @@ A list of modules can also be specified as an array. !!! compat "Julia 1.4" At least Julia 1.4 is required for specifying a module. -See also: [`which`](@ref), [`@which`](@ref Base.@which). +See also: [`which`](@ref) and `@which`. """ function methods(@nospecialize(f), @nospecialize(t), mod::Union{Tuple{Module},AbstractArray{Module},Nothing}=nothing) @@ -1251,7 +1251,7 @@ Returns the method of `f` (a `Method` object) that would be called for arguments If `types` is an abstract type, then the method that would be called by `invoke` is returned. -See also: [`@which`](@ref Base.@which), [`@edit`](@ref Base.@edit), [`parentmodule`](@ref). +See also: [`parentmodule`](@ref), and `@which` and `@edit` in [`InteractiveUtils`](@ref man-interactive-utils). """ function which(@nospecialize(f), @nospecialize(t)) if isa(f, Core.Builtin) diff --git a/base/strings/io.jl b/base/strings/io.jl index fc960452e7592..0c1478aa3b5bb 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -57,7 +57,7 @@ end Print (using [`print`](@ref)) `xs` followed by a newline. If `io` is not supplied, prints to [`stdout`](@ref). -See also: [`show`](@ref), [`@show`](@ref), [`@info`](@ref Logging), [`sprint`](@ref), [`Printf.@printf`](@ref Printf). +See also: [`show`](@ref), [`@show`](@ref), [`@info`](@ref Logging), [`sprint`](@ref), [`Printf.@printf`](@ref man-printf). # Examples ```jldoctest diff --git a/base/threadingconstructs.jl b/base/threadingconstructs.jl index b0b7037c4c3a5..77d572e725c08 100644 --- a/base/threadingconstructs.jl +++ b/base/threadingconstructs.jl @@ -117,7 +117,7 @@ The default schedule (used when no `schedule` argument is present) is subject to !!! compat "Julia 1.5" The `schedule` argument is available as of Julia 1.5. -See also: [`@spawn`](@ref Threads.@spawn), [`nthreads()`](@ref Threads.nthreads), [`threadid()`](@ref Threads.threadid), [Distributed.pmap](@ref Distributed), `BLAS.set_num_threads` in [`LinearAlgebra`](@ref). +See also: [`@spawn`](@ref Threads.@spawn), [`nthreads()`](@ref Threads.nthreads), [`threadid()`](@ref Threads.threadid), [Distributed.pmap](@ref Distributed), `BLAS.set_num_threads` in [`LinearAlgebra`](@ref man-linalg). """ macro threads(args...) na = length(args) diff --git a/doc/src/base/base.md b/doc/src/base/base.md index a54d051b1016b..cef6e4e9f9cd2 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -30,10 +30,7 @@ Base.MainInclude.include Base.include_string Base.include_dependency Base.which(::Any, ::Any) -Base.@which Base.methods -Base.@less -Base.@edit Base.@show ans Base.active_project @@ -246,6 +243,7 @@ new Base.:(|>) Base.:(∘) Base.ComposedFunction +Base.splat ``` ## Syntax diff --git a/stdlib/InteractiveUtils/docs/src/index.md b/stdlib/InteractiveUtils/docs/src/index.md index 6b996fb333fc5..71499744ecb1d 100644 --- a/stdlib/InteractiveUtils/docs/src/index.md +++ b/stdlib/InteractiveUtils/docs/src/index.md @@ -1,4 +1,4 @@ -# Interactive Utilities +# [Interactive Utilities](@id man-interactive-utils) This module is intended for interactive work. It is loaded automaticaly in [interactive mode](@ref command-line-options). diff --git a/stdlib/Printf/docs/src/index.md b/stdlib/Printf/docs/src/index.md index 828e527ed0cad..48e38e2b2ce5b 100644 --- a/stdlib/Printf/docs/src/index.md +++ b/stdlib/Printf/docs/src/index.md @@ -1,4 +1,4 @@ -# Printf +# [Printf](@id man-printf) ```@docs Printf.@printf From 0934b8bf5b60229a11a3c42941587b057d1da288 Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Tue, 22 Dec 2020 02:25:17 +0100 Subject: [PATCH 13/28] refs to distributed --- base/threadingconstructs.jl | 8 ++++++-- stdlib/Distributed/docs/src/index.md | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/base/threadingconstructs.jl b/base/threadingconstructs.jl index 77d572e725c08..b0a1d062936c5 100644 --- a/base/threadingconstructs.jl +++ b/base/threadingconstructs.jl @@ -16,7 +16,9 @@ threadid() = Int(ccall(:jl_threadid, Int16, ())+1) Get the number of threads available to the Julia process. This is the inclusive upper bound on [`threadid()`](@ref). -See also: `BLAS.get_num_threads` and `BLAS.set_num_threads` in the [`LinearAlgebra`](@ref man-linalg) standard library. +See also: `BLAS.get_num_threads` and `BLAS.set_num_threads` in the +[`LinearAlgebra`](@ref man-linalg) standard library, and `nprocs()` in the +[`Distributed`](@ref man-distributed) standard library. """ nthreads() = Int(unsafe_load(cglobal(:jl_n_threads, Cint))) @@ -117,7 +119,9 @@ The default schedule (used when no `schedule` argument is present) is subject to !!! compat "Julia 1.5" The `schedule` argument is available as of Julia 1.5. -See also: [`@spawn`](@ref Threads.@spawn), [`nthreads()`](@ref Threads.nthreads), [`threadid()`](@ref Threads.threadid), [Distributed.pmap](@ref Distributed), `BLAS.set_num_threads` in [`LinearAlgebra`](@ref man-linalg). +See also: [`@spawn`](@ref Threads.@spawn), [`nthreads()`](@ref Threads.nthreads), +[`threadid()`](@ref Threads.threadid), `pmap` in [`Distributed`](@ref man-distributed), +`BLAS.set_num_threads` in [`LinearAlgebra`](@ref man-linalg). """ macro threads(args...) na = length(args) diff --git a/stdlib/Distributed/docs/src/index.md b/stdlib/Distributed/docs/src/index.md index 1b1675eccc1a2..dc8cef5e22d92 100644 --- a/stdlib/Distributed/docs/src/index.md +++ b/stdlib/Distributed/docs/src/index.md @@ -1,4 +1,4 @@ -# Distributed Computing +# [Distributed Computing](@id man-distributed) ```@docs Distributed.addprocs From ae2468b7c9596231cd590552fcd0f476752034c4 Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Tue, 22 Dec 2020 02:27:07 +0100 Subject: [PATCH 14/28] inf + nan examples --- base/float.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/base/float.jl b/base/float.jl index f5da9380a1588..01d42cdd455d8 100644 --- a/base/float.jl +++ b/base/float.jl @@ -37,13 +37,16 @@ const Inf = Inf64 Positive infinity of type [`Float64`](@ref). -See also: [`isfinite`](@ref), [`NaN`](@ref), [`Inf32`](@ref). +See also: [`isfinite`](@ref), [`typemax`](@ref), [`NaN`](@ref), [`Inf32`](@ref). # Examples ```jldoctest julia> π/0 Inf +julia> +1.0 / -0.0 +-Inf + julia> ℯ^-Inf 0.0 ``` @@ -65,6 +68,9 @@ NaN julia> Inf - Inf NaN + +julia> NaN == NaN, isequal(NaN, NaN), NaN === NaN +(false, true, true) ``` """ NaN, NaN64 From 2fa25caef9618ad85a8905e8166b82bdc54b2470 Mon Sep 17 00:00:00 2001 From: Michael Abbott Date: Tue, 22 Dec 2020 02:42:58 +0100 Subject: [PATCH 15/28] fix a rebase mistake, findmax has moved --- base/array.jl | 142 ------------------------------------------------- base/reduce.jl | 9 +++- 2 files changed, 8 insertions(+), 143 deletions(-) diff --git a/base/array.jl b/base/array.jl index e219904fb6101..e6e64c03b8aaf 100644 --- a/base/array.jl +++ b/base/array.jl @@ -2242,148 +2242,6 @@ findall(x::Bool) = x ? [1] : Vector{Int}() findall(testf::Function, x::Number) = testf(x) ? [1] : Vector{Int}() findall(p::Fix2{typeof(in)}, x::Number) = x in p.x ? [1] : Vector{Int}() -""" - findmax(itr) -> (x, index) - -Return the maximum element of the collection `itr` and its index or key. -If there are multiple maximal elements, then the first one will be returned. -If any data element is `NaN`, this element is returned. -The result is in line with `max`. - -The collection must not be empty. - -See also: [`findmin`](@ref), [`argmax`](@ref), [`maximum`](@ref). - -# Examples -```jldoctest -julia> findmax([8,0.1,-9,pi]) -(8.0, 1) - -julia> findmax([1,7,7,6]) -(7, 2) - -julia> findmax([1,7,7,NaN]) -(NaN, 4) -``` -""" -findmax(a) = _findmax(a, :) - -function _findmax(a, ::Colon) - p = pairs(a) - y = iterate(p) - if y === nothing - throw(ArgumentError("collection must be non-empty")) - end - (mi, m), s = y - i = mi - while true - y = iterate(p, s) - y === nothing && break - m != m && break - (i, ai), s = y - if ai != ai || isless(m, ai) - m = ai - mi = i - end - end - return (m, mi) -end - -""" - findmin(itr) -> (x, index) - -Return the minimum element of the collection `itr` and its index or key. -If there are multiple minimal elements, then the first one will be returned. -If any data element is `NaN`, this element is returned. -The result is in line with `min`. - -The collection must not be empty. - -See also: [`findmax`](@ref), [`argmin`](@ref), [`minimum`](@ref). - -# Examples -```jldoctest -julia> findmin([8,0.1,-9,pi]) -(-9.0, 3) - -julia> findmin([7,1,1,6]) -(1, 2) - -julia> findmin([7,1,1,NaN]) -(NaN, 4) -``` -""" -findmin(a) = _findmin(a, :) - -function _findmin(a, ::Colon) - p = pairs(a) - y = iterate(p) - if y === nothing - throw(ArgumentError("collection must be non-empty")) - end - (mi, m), s = y - i = mi - while true - y = iterate(p, s) - y === nothing && break - m != m && break - (i, ai), s = y - if ai != ai || isless(ai, m) - m = ai - mi = i - end - end - return (m, mi) -end - -""" - argmax(itr) - -Return the index or key of the maximum element in a collection. -If there are multiple maximal elements, then the first one will be returned. - -The collection must not be empty. - -See also: [`argmin`](@ref), [`findmax`](@ref). - -# Examples -```jldoctest -julia> argmax([8,0.1,-9,pi]) -1 - -julia> argmax([1,7,7,6]) -2 - -julia> argmax([1,7,7,NaN]) -4 -``` -""" -argmax(a) = findmax(a)[2] - -""" - argmin(itr) - -Return the index or key of the minimum element in a collection. -If there are multiple minimal elements, then the first one will be returned. - -The collection must not be empty. - -See also: [`argmax`](@ref), [`findmin`](@ref). - -# Examples -```jldoctest -julia> argmin([8,0.1,-9,pi]) -3 - -julia> argmin([7,1,1,6]) -2 - -julia> argmin([7,1,1,NaN]) -4 -``` -""" -argmin(a) = findmin(a)[2] - # similar to Matlab's ismember """ indexin(a, b) diff --git a/base/reduce.jl b/base/reduce.jl index 4efd636bf4eb2..9581e20f11102 100644 --- a/base/reduce.jl +++ b/base/reduce.jl @@ -808,6 +808,8 @@ Return the maximal element of the collection `itr` and its index or key. If there are multiple maximal elements, then the first one will be returned. Values are compared with `isless`. +See also: [`findmin`](@ref), [`argmax`](@ref), [`maximum`](@ref). + # Examples ```jldoctest @@ -865,6 +867,8 @@ Return the minimal element of the collection `itr` and its index or key. If there are multiple minimal elements, then the first one will be returned. `NaN` is treated as less than all other values except `missing`. +See also: [`findmax`](@ref), [`argmin`](@ref), [`minimum`](@ref). + # Examples ```jldoctest @@ -915,6 +919,8 @@ The collection must not be empty. Values are compared with `isless`. +See also: [`argmin`](@ref), [`findmax`](@ref). + # Examples ```jldoctest julia> argmax([8, 0.1, -9, pi]) @@ -952,7 +958,6 @@ julia> argmin(x -> -x^3 + x^2 - 10, -5:5) julia> argmin(acos, 0:0.1:1) 1.0 - ``` """ argmin(f, domain) = findmin(f, domain)[2] @@ -967,6 +972,8 @@ The collection must not be empty. `NaN` is treated as less than all other values except `missing`. +See also: [`argmax`](@ref), [`findmin`](@ref). + # Examples ```jldoctest julia> argmin([8, 0.1, -9, pi]) From b51f4d6b53b444c94c6569d5006bfad4342a0052 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Sun, 11 Apr 2021 20:56:13 -0400 Subject: [PATCH 16/28] Apply 16 suggestions from code review Co-authored-by: Jameson Nash --- base/abstractarray.jl | 4 ++-- base/array.jl | 2 +- base/docs/basedocs.jl | 4 ++-- base/essentials.jl | 3 ++- base/file.jl | 6 ++---- base/iterators.jl | 4 ++-- base/mathconstants.jl | 4 ++-- base/number.jl | 2 +- base/permuteddimsarray.jl | 2 +- base/promotion.jl | 2 +- base/strings/io.jl | 2 +- base/tuple.jl | 2 +- stdlib/Printf/docs/src/index.md | 2 +- 13 files changed, 19 insertions(+), 20 deletions(-) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 342765b6a41ad..62c660ed83739 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -393,7 +393,7 @@ 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), [`tail`](@ref Base.tail). +See also: [`only`](@ref), [`firstindex`](@ref), [`last`](@ref). # Examples ```jldoctest @@ -2184,7 +2184,7 @@ julia> res 16 49 -julia> foreach((x,y) -> println(x," & ",y), tri, 1:100) +julia> foreach((x, y) -> println(x, " & ", y), tri, 1:100) 1 & 1 4 & 2 7 & 3 diff --git a/base/array.jl b/base/array.jl index a741ad90dd44e..06153d72608a4 100644 --- a/base/array.jl +++ b/base/array.jl @@ -1162,7 +1162,7 @@ Remove an item in `collection` and return it. If `collection` is an ordered container, the last item is returned; for unordered containers, an arbitrary element is returned. -See also: [`popat!`](@ref), [`delete!`](@ref), [`splice!`](@ref), [`push!`](@ref). +See also: [`popfirst!`](@ref), [`popat!`](@ref), [`delete!`](@ref), [`deleteat!`](@ref), [`splice!`](@ref), and [`push!`](@ref). # Examples ```jldoctest diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index 2efbd62a25f34..56f04166df6ff 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -1856,8 +1856,8 @@ julia> tuple(1, 'b', pi) julia> ans === (1, 'b', π) true -julia> Tuple([1, 2, pi]) # takes a collection -(1.0, 2.0, 3.141592653589793) +julia> Tuple(Real[1, 2, pi]) # takes a collection +(1, 2, π) ``` """ tuple diff --git a/base/essentials.jl b/base/essentials.jl index ad07bf905f5f0..d9a9ab4b0d721 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -131,7 +131,8 @@ end Tests whether variable `s` is defined in the current scope. -See also [`isdefined`](@ref), [`isassigned`](@ref). +See also [`isdefined`](@ref) for field properties and [`isassigned`](@ref) for +array indexes or [`haskey`](@ref) for other mappings. # Examples ```jldoctest diff --git a/base/file.jl b/base/file.jl index 4edc25106d958..3a038863107bc 100644 --- a/base/file.jl +++ b/base/file.jl @@ -738,12 +738,10 @@ end Apply the function `f` to the result of [`mktempdir(parent; prefix)`](@ref) and remove the temporary directory all of its contents upon completion. -<<<<<<< HEAD +See also: [`mktemp`](@ref), [`mkdir`](@ref). + !!! compat "Julia 1.2" The `prefix` keyword argument was added in Julia 1.2. -======= -See also: [`mktemp`](@ref), [`mkdir`](@ref). ->>>>>>> another batch of see also additions """ function mktempdir(fn::Function, parent::AbstractString=tempdir(); prefix::AbstractString=temp_prefix) diff --git a/base/iterators.jl b/base/iterators.jl index 45d24b104d496..e3a1dab987a24 100644 --- a/base/iterators.jl +++ b/base/iterators.jl @@ -554,7 +554,7 @@ rest(itr) = itr Returns the first element and an iterator over the remaining elements. -See also: [`Iterators.drop`](@ref), [`Iterators.take`](@ref), [`Base.tail`](@ref). +See also: [`Iterators.drop`](@ref), [`Iterators.take`](@ref). # Examples ```jldoctest @@ -925,7 +925,7 @@ Return an iterator over the product of several iterators. Each generated element a tuple whose `i`th element comes from the `i`th argument iterator. The first iterator changes the fastest. -See also: [`zip`](@ref), [`Iterators.flatten`](@ref), `Base.splat`. +See also: [`zip`](@ref), [`Iterators.flatten`](@ref). # Examples ```jldoctest diff --git a/base/mathconstants.jl b/base/mathconstants.jl index 3c568e27daecb..156dc9e1ce39a 100644 --- a/base/mathconstants.jl +++ b/base/mathconstants.jl @@ -23,7 +23,7 @@ Base.@irrational catalan 0.91596559417721901505 catalan The constant pi. -Unicode `π` can be typed by tab-completing `\\pi` in the Julia REPL. +Unicode `π` can be typed by writing `\\pi` then pressing tab in the Julia REPL, and in many editors. See also: [`sinpi`](@ref), [`sincospi`](@ref), [`deg2rad`](@ref). @@ -44,7 +44,7 @@ julia> 1/2pi The constant ℯ. -Unicode `ℯ` can be typed by tab-completing `\\euler` in the Julia REPL. +Unicode `ℯ` can be typed by writing `\\euler` and pressing tab in the Julia REPL, and in many editors. See also: [`exp`](@ref), [`cis`](@ref), [`cispi`](@ref). diff --git a/base/number.jl b/base/number.jl index ce5f988cf2365..8dfa56aa0f61a 100644 --- a/base/number.jl +++ b/base/number.jl @@ -112,7 +112,7 @@ copy(x::Number) = x # some code treats numbers as collection-like Returns `true` if the value of the sign of `x` is negative, otherwise `false`. -See also [`sign`](@ref). +See also [`sign`](@ref) and [`copysign`](@ref). # Examples ```jldoctest diff --git a/base/permuteddimsarray.jl b/base/permuteddimsarray.jl index 875383ca7258e..8e8e5fbc7a42d 100644 --- a/base/permuteddimsarray.jl +++ b/base/permuteddimsarray.jl @@ -83,7 +83,7 @@ end """ permutedims(A::AbstractArray, perm) -Permute the dimensions of array `A`. `perm` is a vector or a tuple of length `ndims(A)`, +Permute the dimensions of array `A`. `perm` is a vector or a tuple of length `ndims(A)` specifying the permutation. See also: [`permutedims!`](@ref), [`PermutedDimsArray`](@ref), [`transpose`](@ref), [`invperm`](@ref). diff --git a/base/promotion.jl b/base/promotion.jl index 67166a3952ea6..43add6cbf5f62 100644 --- a/base/promotion.jl +++ b/base/promotion.jl @@ -144,7 +144,7 @@ Compute a type that contains both `T` and `S`, which could be either a parent of both types, or a `Union` if appropriate. Falls back to [`typejoin`](@ref). -See also: [`promote`](@ref), [`promote_type`](@ref). +See instead [`promote`](@ref), [`promote_type`](@ref). # Examples ```jldoctest diff --git a/base/strings/io.jl b/base/strings/io.jl index 561d8b2ac1c35..5fbf6389fd10b 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -57,7 +57,7 @@ end Print (using [`print`](@ref)) `xs` followed by a newline. If `io` is not supplied, prints to [`stdout`](@ref). -See also: [`show`](@ref), [`@show`](@ref), [`@info`](@ref Logging), [`sprint`](@ref), [`Printf.@printf`](@ref man-printf). +See also: [`@show`](@ref), [`@info`](@ref Logging), [`Printf.@printf`](@ref Printf). # Examples ```jldoctest diff --git a/base/tuple.jl b/base/tuple.jl index 48a03dcf0bc0b..cd98c81356f3f 100644 --- a/base/tuple.jl +++ b/base/tuple.jl @@ -110,7 +110,7 @@ in assignments, like `a, b... = collection`. !!! compat "Julia 1.6" `Base.rest` requires at least Julia 1.6. -See also: [`first`](@ref first), [`tail`](@ref Base.tail), [`Iterators.rest`](@ref). +See also: [`first`](@ref first), [`Iterators.rest`](@ref). # Examples ```jldoctest diff --git a/stdlib/Printf/docs/src/index.md b/stdlib/Printf/docs/src/index.md index 48e38e2b2ce5b..828e527ed0cad 100644 --- a/stdlib/Printf/docs/src/index.md +++ b/stdlib/Printf/docs/src/index.md @@ -1,4 +1,4 @@ -# [Printf](@id man-printf) +# Printf ```@docs Printf.@printf From 5f4284b63873e3942a7f79a27bb705417cce5f69 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Sun, 11 Apr 2021 21:18:12 -0400 Subject: [PATCH 17/28] changes to Matrix & Vector re undef --- base/array.jl | 5 +++++ base/docs/basedocs.jl | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/base/array.jl b/base/array.jl index 06153d72608a4..f173f7d59d73b 100644 --- a/base/array.jl +++ b/base/array.jl @@ -54,6 +54,8 @@ Array One-dimensional dense array with elements of type `T`, often used to represent a mathematical vector. Alias for [`Array{T,1}`](@ref). + +See also [`empty`](@ref), [`similar`](@ref) and [`zero`](@ref) for creating vectors. """ const Vector{T} = Array{T,1} @@ -62,6 +64,9 @@ const Vector{T} = Array{T,1} Two-dimensional dense array with elements of type `T`, often used to represent a mathematical matrix. Alias for [`Array{T,2}`](@ref). + +See also [`fill`](@ref), [`zeros`](@ref), [`undef`](@ref) and [`similar`](@ref) +for creating matrices. """ const Matrix{T} = Array{T,2} """ diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index 56f04166df6ff..5a9ef2ab7a25b 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -1980,8 +1980,6 @@ isdefined Construct an uninitialized [`Vector{T}`](@ref) of length `n`. -See also [`undef`](@ref), [`similar`](@ref). - # Examples ```julia-repl julia> Vector{Float64}(undef, 3) @@ -2032,8 +2030,6 @@ Vector{T}(::Missing, n) Construct an uninitialized [`Matrix{T}`](@ref) of size `m`×`n`. -See also [`undef`](@ref), [`similar`](@ref). - # Examples ```julia-repl julia> Matrix{Float64}(undef, 2, 3) @@ -2092,9 +2088,8 @@ containing elements of type `T`. `N` can either be supplied explicitly, as in `Array{T,N}(undef, dims)`, or be determined by the length or number of `dims`. `dims` may be a tuple or a series of integer arguments corresponding to the lengths in each dimension. If the rank `N` is supplied explicitly, then it must -match the length or number of `dims`. - -See also: [`undef`](@ref), [`similar`](@ref). +match the length or number of `dims`. Here [`undef`](@ref) is +the [`UndefInitializer`](@ref). # Examples ```julia-repl From c95fd9cbd4d91db54337ddd001d2ebcc2c46bb77 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Sun, 11 Apr 2021 21:18:23 -0400 Subject: [PATCH 18/28] better foreach example --- base/abstractarray.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 62c660ed83739..45a6118412712 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -2184,10 +2184,10 @@ julia> res 16 49 -julia> foreach((x, y) -> println(x, " & ", y), tri, 1:100) -1 & 1 -4 & 2 -7 & 3 +julia> foreach((x, y) -> println(x, " with ", y), tri, 'a':'z') +1 with a +4 with b +7 with c ``` """ foreach(f) = (f(); nothing) From 273cd205f66934ad470b308259f705c79cf953d8 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Sun, 11 Apr 2021 21:37:38 -0400 Subject: [PATCH 19/28] clamp and trunk fixup --- base/math.jl | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/base/math.jl b/base/math.jl index 7551743097884..4dfa5835edf0f 100644 --- a/base/math.jl +++ b/base/math.jl @@ -47,17 +47,17 @@ end Return `x` if `lo <= x <= hi`. If `x > hi`, return `hi`. If `x < lo`, return `lo`. Arguments are promoted to a common type. -See also [`clamp!`](@ref), [`trunc`](@ref). +See also [`clamp!`](@ref), [min](@ref), [max](@ref). # Examples ```jldoctest -julia> clamp.([pi, 1.0, big(10.)], 2., 9.) +julia> clamp.([pi, 1.0, big(10)], 2.0, 9.0) 3-element Vector{BigFloat}: 3.141592653589793238462643383279502884197169399375105820974944592307816406286198 2.0 9.0 -julia> clamp.([11,8,5],10,6) # an example where lo > hi +julia> clamp.([11, 8, 5], 10, 6) # an example where lo > hi 3-element Vector{Int64}: 6 6 @@ -75,12 +75,18 @@ clamp(x::X, lo::L, hi::H) where {X,L,H} = Clamp `x` between `typemin(T)` and `typemax(T)` and convert the result to type `T`. +See also [`trunc`](@ref). + # Examples ```jldoctest julia> clamp(200, Int8) 127 + julia> clamp(-200, Int8) -128 + +julia> trunc(Int, 4pi^2) +39 ``` """ clamp(x, ::Type{T}) where {T<:Integer} = clamp(x, typemin(T), typemax(T)) % T @@ -91,6 +97,19 @@ clamp(x, ::Type{T}) where {T<:Integer} = clamp(x, typemin(T), typemax(T)) % T Restrict values in `array` to the specified range, in-place. See also [`clamp`](@ref). + +# Examples +```jldoctest +julia> row = collect(-4:4)'; + +julia> clamp!(row, 0, Inf) +1×9 adjoint(::Vector{Int64}) with eltype Int64: + 0 0 0 0 0 1 2 3 4 + +julia> clamp.((-4:4)', 0, Inf) +1×9 Matrix{Float64}: + 0.0 0.0 0.0 0.0 0.0 1.0 2.0 3.0 4.0 +``` """ function clamp!(x::AbstractArray, lo, hi) @inbounds for i in eachindex(x) From bacc03eb1ce9425f4b4bf475f30ac2b916841bae Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Sun, 11 Apr 2021 21:41:53 -0400 Subject: [PATCH 20/28] space --- base/docs/basedocs.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index 5a9ef2ab7a25b..6fbae648a8d06 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -2088,7 +2088,7 @@ containing elements of type `T`. `N` can either be supplied explicitly, as in `Array{T,N}(undef, dims)`, or be determined by the length or number of `dims`. `dims` may be a tuple or a series of integer arguments corresponding to the lengths in each dimension. If the rank `N` is supplied explicitly, then it must -match the length or number of `dims`. Here [`undef`](@ref) is +match the length or number of `dims`. Here [`undef`](@ref) is the [`UndefInitializer`](@ref). # Examples From 0d4a562ba17299750183135bd9b8c2287a86284a Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Sun, 11 Apr 2021 21:43:01 -0400 Subject: [PATCH 21/28] Update base/operators.jl Co-authored-by: Jameson Nash --- base/operators.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/operators.jl b/base/operators.jl index 67455083be0b6..1182f2364b567 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -1006,7 +1006,7 @@ julia> fs = [ julia> ∘(fs...)(3) 3.0 ``` -See also [`ComposedFunction`](@ref), [`!`](@ref). +See also [`ComposedFunction`](@ref), [`!f::Function`](@ref). """ function ∘ end From e23bf29f03002d31f6c629a6fe8db94b0a1cfe9c Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Sun, 11 Apr 2021 22:22:57 -0400 Subject: [PATCH 22/28] missing backticks --- base/math.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/math.jl b/base/math.jl index 4dfa5835edf0f..d66e9805c1e7f 100644 --- a/base/math.jl +++ b/base/math.jl @@ -47,7 +47,7 @@ end Return `x` if `lo <= x <= hi`. If `x > hi`, return `hi`. If `x < lo`, return `lo`. Arguments are promoted to a common type. -See also [`clamp!`](@ref), [min](@ref), [max](@ref). +See also [`clamp!`](@ref), [`min`](@ref), [`max`](@ref). # Examples ```jldoctest From 924f0fc13e18d3426ee07eab340216923d563f65 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Sun, 11 Apr 2021 22:24:59 -0400 Subject: [PATCH 23/28] target for Base.empty --- doc/src/base/arrays.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/base/arrays.md b/doc/src/base/arrays.md index 4c8e08c402621..f8c014677f6c9 100644 --- a/doc/src/base/arrays.md +++ b/doc/src/base/arrays.md @@ -40,6 +40,7 @@ Base.trues Base.falses Base.fill Base.fill! +Base.empty Base.similar ``` From 2d51919a785a4a93262a6f52bb1431008f1f845f Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Sun, 11 Apr 2021 23:20:46 -0400 Subject: [PATCH 24/28] println --- base/strings/io.jl | 7 ++++--- stdlib/Printf/docs/src/index.md | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/base/strings/io.jl b/base/strings/io.jl index 5fbf6389fd10b..d889f1f64b125 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -57,7 +57,8 @@ end Print (using [`print`](@ref)) `xs` followed by a newline. If `io` is not supplied, prints to [`stdout`](@ref). -See also: [`@show`](@ref), [`@info`](@ref Logging), [`Printf.@printf`](@ref Printf). +See also [`@show`](@ref) to print variables names with values, +and [`Printf.@printf`](@ref man-printf) to format numbers. # Examples ```jldoctest @@ -66,10 +67,10 @@ Hello, world julia> io = IOBuffer(); -julia> println(io, "Hello, world") +julia> println(io, "Hello", ',', " world.") julia> String(take!(io)) -"Hello, world\\n" +"Hello, world.\\n" ``` """ println(io::IO, xs...) = print(io, xs..., "\n") diff --git a/stdlib/Printf/docs/src/index.md b/stdlib/Printf/docs/src/index.md index 828e527ed0cad..48e38e2b2ce5b 100644 --- a/stdlib/Printf/docs/src/index.md +++ b/stdlib/Printf/docs/src/index.md @@ -1,4 +1,4 @@ -# Printf +# [Printf](@id man-printf) ```@docs Printf.@printf From e4cfee2ece83e2618783b789c1e3c2368dba66e6 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Thu, 15 Apr 2021 20:47:38 -0400 Subject: [PATCH 25/28] Apply 2 suggestions from code review Co-authored-by: Jameson Nash --- base/irrationals.jl | 2 +- base/strings/io.jl | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/base/irrationals.jl b/base/irrationals.jl index b1ecaf8557090..4258bc44ee551 100644 --- a/base/irrationals.jl +++ b/base/irrationals.jl @@ -19,7 +19,7 @@ for integers `n` will give a rational result when `n` is a perfect square), then abstract type AbstractIrrational <: Real end """ - Irrational{sym} <: AbstractIrrational +`Irrational{sym}` <: [`AbstractIrrational`](@ref) Number type representing an exact irrational value denoted by the symbol `sym`, such as [`π`](@ref pi), [`ℯ`](@ref) and [`γ`](@ref Base.MathConstants.eulergamma). diff --git a/base/strings/io.jl b/base/strings/io.jl index d889f1f64b125..3ffcca7d420a6 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -57,9 +57,6 @@ end Print (using [`print`](@ref)) `xs` followed by a newline. If `io` is not supplied, prints to [`stdout`](@ref). -See also [`@show`](@ref) to print variables names with values, -and [`Printf.@printf`](@ref man-printf) to format numbers. - # Examples ```jldoctest julia> println("Hello, world") From 54e6a758ae6670695bae113e579a4bdabf589ded Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Thu, 15 Apr 2021 21:08:36 -0400 Subject: [PATCH 26/28] restore exp2 --- base/special/exp.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/special/exp.jl b/base/special/exp.jl index 5dffcde385812..8b53628b09a34 100644 --- a/base/special/exp.jl +++ b/base/special/exp.jl @@ -279,6 +279,8 @@ julia> exp(1.0) Compute the base 2 exponential of `x`, in other words ``2^x``. +See also [`ldexp`](@ref), [`<<`](@ref). + # Examples ```jldoctest julia> exp2(5) From e54da9ebb351fe9d3c4413ed15efc384820b1017 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Thu, 15 Apr 2021 21:10:56 -0400 Subject: [PATCH 27/28] and add some exp links + examples --- base/special/exp.jl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/base/special/exp.jl b/base/special/exp.jl index 8b53628b09a34..9750d1a642258 100644 --- a/base/special/exp.jl +++ b/base/special/exp.jl @@ -264,12 +264,17 @@ end @doc """ exp(x) -Compute the natural base exponential of `x`, in other words ``e^x``. +Compute the natural base exponential of `x`, in other words ``ℯ^x``. + +See also [`exp2`](@ref), [`exp10`](@ref) and [`cis`](@ref). # Examples ```jldoctest julia> exp(1.0) 2.718281828459045 + +julia> exp(im * pi) == cis(pi) +true ``` """ exp(x::Real) @@ -285,6 +290,12 @@ See also [`ldexp`](@ref), [`<<`](@ref). ```jldoctest julia> exp2(5) 32.0 + +julia> 2^5 +32 + +julia> exp2(63) > typemax(Int) +true ``` """ exp2(x) @@ -298,6 +309,9 @@ Compute the base 10 exponential of `x`, in other words ``10^x``. ```jldoctest julia> exp10(2) 100.0 + +julia> 10^2 +100 ``` """ exp10(x) From cf990c6e914b271f9e517cd452c6dd18687e1d6a Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Thu, 15 Apr 2021 22:44:05 -0400 Subject: [PATCH 28/28] revert Irrational --- base/irrationals.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/irrationals.jl b/base/irrationals.jl index 4258bc44ee551..b1ecaf8557090 100644 --- a/base/irrationals.jl +++ b/base/irrationals.jl @@ -19,7 +19,7 @@ for integers `n` will give a rational result when `n` is a perfect square), then abstract type AbstractIrrational <: Real end """ -`Irrational{sym}` <: [`AbstractIrrational`](@ref) + Irrational{sym} <: AbstractIrrational Number type representing an exact irrational value denoted by the symbol `sym`, such as [`π`](@ref pi), [`ℯ`](@ref) and [`γ`](@ref Base.MathConstants.eulergamma).