Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More doctests and cleanup for intfuncs #22515

Merged
merged 10 commits into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More doctests and Example{s} inserting
  • Loading branch information
kshyatt committed Jun 25, 2017
commit 20e24b2d9a847340d72d19b59bff74c7eb20b227
4 changes: 4 additions & 0 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,7 @@ For multiple iterable arguments, `f` is called elementwise.
`foreach` should be used instead of `map` when the results of `f` are not
needed, for example in `foreach(println, array)`.

# Example
```jldoctest
julia> a = 1:3:7;

Expand Down Expand Up @@ -1745,6 +1746,7 @@ 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`.

# Examples
```jldoctest
julia> a = reshape(collect(1:16),(2,2,2,2))
2×2×2×2 Array{Int64,4}:
Expand Down Expand Up @@ -1879,6 +1881,7 @@ map(f, A::Union{AbstractArray,AbstractSet,Associative}) = collect_similar(A, Gen
Transform collection `c` by applying `f` to each element. For multiple collection arguments,
apply `f` elementwise.

# Examples
```jldoctest
julia> map(x -> x * 2, [1, 2, 3])
3-element Array{Int64,1}:
Expand Down Expand Up @@ -1921,6 +1924,7 @@ end
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.

# Example
```jldoctest
julia> x = zeros(3);

Expand Down
7 changes: 7 additions & 0 deletions base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Reshape the array `a` as a one-dimensional column vector. The resulting array
shares the same underlying data as `a`, so modifying one will also modify the
other.

# Example
```jldoctest
julia> a = [1 2 3; 4 5 6]
2×3 Array{Int64,2}:
Expand Down Expand Up @@ -48,6 +49,7 @@ 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`.

# Example
```jldoctest
julia> a = reshape(collect(1:4),(2,2,1,1))
2×2×1×1 Array{Int64,4}:
Expand Down Expand Up @@ -101,6 +103,7 @@ imag(x::AbstractArray{<:Real}) = zero(x)
Return all the data of `A` where the index for dimension `d` equals `i`. Equivalent to
`A[:,:,...,i,:,:,...]` where `i` is in position `d`.

# Example
```jldoctest
julia> A = [1 2 3 4; 5 6 7 8]
2×4 Array{Int64,2}:
Expand All @@ -125,6 +128,7 @@ end

Reverse `A` in dimension `d`.

# Example
```jldoctest
julia> b = [1 2; 3 4]
2×2 Array{Int64,2}:
Expand Down Expand Up @@ -177,6 +181,7 @@ circshift(a::AbstractArray, shiftamt::DimsInteger) = circshift!(similar(a), a, s
Circularly shift the data in an array. The second argument is a vector giving the amount to
shift in each dimension.

# Example
```jldoctest
julia> b = reshape(collect(1:16), (4,4))
4×4 Array{Int64,2}:
Expand Down Expand Up @@ -281,6 +286,7 @@ end
Construct a matrix by repeating the given matrix (or vector) `m` times in dimension 1 and `n` times in
dimension 2.

# Examples
```jldoctest
julia> repmat([1, 2, 3], 2)
6-element Array{Int64,1}:
Expand Down Expand Up @@ -337,6 +343,7 @@ repeated. The i-th element of `outer` specifies the number of times that a slice
i-th dimension of `A` should be repeated. If `inner` or `outer` are omitted, no repetition
is performed.

# Examples
```jldoctest
julia> repeat(1:2, inner=2)
4-element Array{Int64,1}:
Expand Down
7 changes: 7 additions & 0 deletions base/arraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Transform an array to its complex conjugate in-place.

See also [`conj`](@ref).

# Example
```jldoctest
julia> A = [1+im 2-im; 2+2im 3+im]
2×2 Array{Complex{Int64},2}:
Expand Down Expand Up @@ -116,6 +117,7 @@ end

Rotate matrix `A` left 90 degrees.

# Example
```jldoctest
julia> a = [1 2; 3 4]
2×2 Array{Int64,2}:
Expand Down Expand Up @@ -143,6 +145,7 @@ end

Rotate matrix `A` right 90 degrees.

# Example
```jldoctest
julia> a = [1 2; 3 4]
2×2 Array{Int64,2}:
Expand All @@ -169,6 +172,7 @@ end

Rotate matrix `A` 180 degrees.

# Example
```jldoctest
julia> a = [1 2; 3 4]
2×2 Array{Int64,2}:
Expand Down Expand Up @@ -196,6 +200,7 @@ end
Rotate matrix `A` left 90 degrees an integer `k` number of times.
If `k` is zero or a multiple of four, this is equivalent to a `copy`.

# Examples
```jldoctest
julia> a = [1 2; 3 4]
2×2 Array{Int64,2}:
Expand Down Expand Up @@ -235,6 +240,7 @@ end
Rotate matrix `A` right 90 degrees an integer `k` number of times. If `k` is zero or a
multiple of four, this is equivalent to a `copy`.

# Examples
```jldoctest
julia> a = [1 2; 3 4]
2×2 Array{Int64,2}:
Expand Down Expand Up @@ -269,6 +275,7 @@ rotr90(A::AbstractMatrix, k::Integer) = rotl90(A,-k)
Rotate matrix `A` 180 degrees an integer `k` number of times.
If `k` is even, this is equivalent to a `copy`.

# Examples
```jldoctest
julia> a = [1 2; 3 4]
2×2 Array{Int64,2}:
Expand Down
9 changes: 7 additions & 2 deletions base/combinatorics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ end

Returns `true` if `v` is a valid permutation.

# Examples
```jldoctest
julia> isperm([1; 2])
true
Expand Down Expand Up @@ -100,8 +101,9 @@ to verify that `p` is a permutation.
To return a new permutation, use `v[p]`. Note that this is generally faster than
`permute!(v,p)` for large vectors.

See also [`ipermute!`](@ref)
See also [`ipermute!`](@ref).

# Example
```jldoctest
julia> A = [1, 1, 3, 4];

Expand Down Expand Up @@ -145,8 +147,9 @@ end
"""
ipermute!(v, p)

Like `permute!`, but the inverse of the given permutation is applied.
Like [`permute!`](@ref), but the inverse of the given permutation is applied.

# Example
```jldoctest
julia> A = [1, 1, 3, 4];

Expand All @@ -170,6 +173,7 @@ ipermute!(a, p::AbstractVector) = ipermute!!(a, copymutable(p))
Return the inverse permutation of `v`.
If `B = A[v]`, then `A == B[invperm(v)]`.

# Example
```jldoctest
julia> v = [2; 4; 3; 1];

Expand Down Expand Up @@ -221,6 +225,7 @@ invperm(a::Tuple) = (invperm([a...])...,)
Next integer greater than or equal to `n` that can be written as ``\\prod k_i^{p_i}`` for integers
``p_1``, ``p_2``, etc.

# Example
```jldoctest
julia> nextprod([2, 3], 105)
108
Expand Down
Loading