Skip to content

Commit

Permalink
More doctests and cleanup for intfuncs (#22515)
Browse files Browse the repository at this point in the history
* More doctests and cleanup for intfuncs

* Also more doctests for arrays

* More doctests and Example{s} inserting

* Doctests for DAYS

* Fix some failing doctests

* "fix" failing OffsetArray test

* Address more comments

* fix dropstored!

* Fix leading space

* fix typo

(cherry picked from commit de74614)
  • Loading branch information
kshyatt authored and vtjnash committed Sep 14, 2017
1 parent 36309c2 commit 7b3f765
Show file tree
Hide file tree
Showing 21 changed files with 917 additions and 53 deletions.
6 changes: 5 additions & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ A[iter] = 0
If you supply more than one `AbstractArray` argument, `eachindex` will create an
iterable object that is fast for all arguments (a `UnitRange`
if all inputs have fast linear indexing, a `CartesianRange`
if all inputs have fast linear indexing, a [`CartesianRange`](@ref)
otherwise).
If the arrays have different sizes and/or dimensionalities, `eachindex` returns an
iterable that spans the largest range along each dimension.
Expand Down 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 @@ -1871,6 +1873,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 @@ -1913,6 +1916,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
Loading

0 comments on commit 7b3f765

Please sign in to comment.