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

correct all doctests to account for new whitespace printing #20417

Merged
merged 1 commit into from
Feb 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
correct all doctests to account for new whitespce printing
  • Loading branch information
vtjnash committed Feb 2, 2017
commit c77a2d0b9eff36328a53140d4b23391ea51c4633
39 changes: 18 additions & 21 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ julia> size(A, 2)
3

julia> size(A,3,2)
(4,3)
(4, 3)
```
"""
size{T,N}(t::AbstractArray{T,N}, d) = d <= N ? size(t)[d] : 1
Expand Down Expand Up @@ -48,7 +48,7 @@ Returns the tuple of valid indices for array `A`.
julia> A = ones(5,6,7);

julia> indices(A)
(Base.OneTo(5),Base.OneTo(6),Base.OneTo(7))
(Base.OneTo(5), Base.OneTo(6), Base.OneTo(7))
```
"""
function indices(A)
Expand Down Expand Up @@ -84,7 +84,7 @@ julia> A = ones(5,6,7);
julia> b = linearindices(A);

julia> extrema(b)
(1,210)
(1, 210)
```
"""
linearindices(A) = (@_inline_meta; OneTo(_length(A)))
Expand Down Expand Up @@ -199,7 +199,7 @@ Returns a tuple of the memory strides in each dimension.
julia> A = ones(3,4,5);

julia> strides(A)
(1,3,12)
(1, 3, 12)
```
"""
strides(A::AbstractArray) = _strides((1,), A)
Expand Down Expand Up @@ -716,17 +716,17 @@ julia> for iter in eachindex(A)
@show iter.I[1], iter.I[2]
@show A[iter]
end
(iter.I[1],iter.I[2]) = (1,1)
(iter.I[1], iter.I[2]) = (1, 1)
A[iter] = 1
(iter.I[1],iter.I[2]) = (2,1)
(iter.I[1], iter.I[2]) = (2, 1)
A[iter] = -5
(iter.I[1],iter.I[2]) = (1,2)
(iter.I[1], iter.I[2]) = (1, 2)
A[iter] = 0
(iter.I[1],iter.I[2]) = (2,2)
(iter.I[1], iter.I[2]) = (2, 2)
A[iter] = 0
(iter.I[1],iter.I[2]) = (1,3)
(iter.I[1], iter.I[2]) = (1, 3)
A[iter] = 2
(iter.I[1],iter.I[2]) = (2,3)
(iter.I[1], iter.I[2]) = (2, 3)
A[iter] = 0
```

Expand Down Expand Up @@ -1142,10 +1142,7 @@ julia> vcat(a,b)
11 12 13 14 15

julia> c = ([1 2 3], [4 5 6])
(
[1 2 3],

[4 5 6])
([1 2 3], [4 5 6])

julia> vcat(c...)
2×3 Array{Int64,2}:
Expand Down Expand Up @@ -1185,7 +1182,7 @@ julia> hcat(a,b)
5 14 15

julia> c = ([1; 2; 3], [4; 5; 6])
([1,2,3],[4,5,6])
([1, 2, 3], [4, 5, 6])

julia> hcat(c...)
3×2 Array{Int64,2}:
Expand Down Expand Up @@ -1237,7 +1234,7 @@ row.

```jldoctest
julia> a, b, c, d, e, f = 1, 2, 3, 4, 5, 6
(1,2,3,4,5,6)
(1, 2, 3, 4, 5, 6)

julia> [a b c; d e f]
2×3 Array{Int64,2}:
Expand Down Expand Up @@ -1444,10 +1441,10 @@ Returns a tuple of subscripts into array `a` corresponding to the linear index `
julia> A = ones(5,6,7);

julia> ind2sub(A,35)
(5,1,2)
(5, 1, 2)

julia> ind2sub(A,70)
(5,2,3)
(5, 2, 3)
```
"""
function ind2sub(A::AbstractArray, ind)
Expand Down Expand Up @@ -1517,13 +1514,13 @@ provides the indices of the maximum element.

```jldoctest
julia> ind2sub((3,4),2)
(2,1)
(2, 1)

julia> ind2sub((3,4),3)
(3,1)
(3, 1)

julia> ind2sub((3,4),4)
(1,2)
(1, 2)
```
"""
ind2sub(dims::DimsInteger, ind::Integer) = (@_inline_meta; _ind2sub(dims, ind-1))
Expand Down
18 changes: 9 additions & 9 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1426,15 +1426,15 @@ julia> A = [1 2 0; 0 0 3; 0 4 0]
0 4 0

julia> findn(A)
([1,1,3,2],[1,2,2,3])
([1, 1, 3, 2], [1, 2, 2, 3])

julia> A = zeros(2,2)
2×2 Array{Float64,2}:
0.0 0.0
0.0 0.0

julia> findn(A)
(Int64[],Int64[])
(Int64[], Int64[])
```
"""
function findn(A::AbstractMatrix)
Expand Down Expand Up @@ -1466,7 +1466,7 @@ julia> A = [1 2 0; 0 0 3; 0 4 0]
0 4 0

julia> findnz(A)
([1,1,3,2],[1,2,2,3],[1,2,4,3])
([1, 1, 3, 2], [1, 2, 2, 3], [1, 2, 4, 3])
```
"""
function findnz{T}(A::AbstractMatrix{T})
Expand Down Expand Up @@ -1500,13 +1500,13 @@ The collection must not be empty.

```jldoctest
julia> findmax([8,0.1,-9,pi])
(8.0,1)
(8.0, 1)

julia> findmax([1,7,7,6])
(7,2)
(7, 2)

julia> findmax([1,7,7,NaN])
(7.0,2)
(7.0, 2)
```
"""
function findmax(a)
Expand Down Expand Up @@ -1538,13 +1538,13 @@ The collection must not be empty.

```jldoctest
julia> findmin([8,0.1,-9,pi])
(-9.0,3)
(-9.0, 3)

julia> findmin([7,1,1,6])
(1,2)
(1, 2)

julia> findmin([7,1,1,NaN])
(1.0,2)
(1.0, 2)
```
"""
function findmin(a)
Expand Down
8 changes: 4 additions & 4 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ julia> parse.(Int, ["1", "2"])
2

julia> abs.((1, -2))
(1,2)
(1, 2)

julia> broadcast(+, 1.0, (0, -2.0))
(1.0,-1.0)
(1.0, -1.0)

julia> broadcast(+, 1.0, (0, -2.0), Ref(1))
2-element Array{Float64,1}:
Expand All @@ -383,8 +383,8 @@ julia> broadcast(+, 1.0, (0, -2.0), Ref(1))

julia> (+).([[0,2], [1,3]], Ref{Vector{Int}}([1,-1]))
2-element Array{Array{Int64,1},1}:
[1,1]
[2,2]
[1, 1]
[2, 2]

julia> string.(("one","two","three","four"), ": ", 1:4)
4-element Array{String,1}:
Expand Down
14 changes: 7 additions & 7 deletions base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ julia> fill!(A, 2.)

julia> a = [1, 1, 1]; A = fill!(Vector{Vector{Int}}(3), a); a[1] = 2; A
3-element Array{Array{Int64,1},1}:
[2,1,1]
[2,1,1]
[2,1,1]
[2, 1, 1]
[2, 1, 1]
[2, 1, 1]

julia> x = 0; f() = (global x += 1; x); fill!(Vector{Int}(3), f())
3-element Array{Int64,1}:
Expand Down Expand Up @@ -348,7 +348,7 @@ If `T` is not a bitstype, an error is thrown.
julia> sizeof(Base.LinAlg.LU)
ERROR: argument is an abstract type; size is indeterminate
Stacktrace:
[1] sizeof(::Type{T} where T) at ./essentials.jl:138
[1] sizeof(::Type{T} where T) at ./essentials.jl:147
```
"""
sizeof(::Type)
Expand Down Expand Up @@ -558,7 +558,7 @@ Construct a tuple of the given objects.

```jldoctest
julia> tuple(1, 'a', pi)
(1,'a',π = 3.1415926535897...)
(1, 'a', π = 3.1415926535897...)
```
"""
tuple
Expand Down Expand Up @@ -1002,10 +1002,10 @@ For a given iterable object and iteration state, return the current item and the

```jldoctest
julia> next(1:5, 3)
(3,4)
(3, 4)

julia> next(1:5, 5)
(5,6)
(5, 6)
```
"""
next
Expand Down
2 changes: 1 addition & 1 deletion base/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ julia> macro m()
@m (macro with 1 method)

julia> M.f()
(1,2)
(1, 2)
```
With `@macroexpand` the expression expands where `@macroexpand` appears in the code (module
`M` in the example). With `macroexpand` the expression expands in the current module where
Expand Down
4 changes: 2 additions & 2 deletions base/intfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ coefficients, i.e. the integer coefficients `u` and `v` that satisfy

```jldoctest
julia> gcdx(12, 42)
(6,-3,1)
(6, -3, 1)
```

```jldoctest
julia> gcdx(240, 46)
(2,-9,47)
(2, -9, 47)
```

!!! note
Expand Down
12 changes: 6 additions & 6 deletions base/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ julia> b = ["e","d","b","c","a"]
"a"

julia> c = zip(a,b)
Base.Iterators.Zip2{UnitRange{Int64},Array{String,1}}(1:5,String["e","d","b","c","a"])
Base.Iterators.Zip2{UnitRange{Int64},Array{String,1}}(1:5, String["e", "d", "b", "c", "a"])

julia> length(c)
5

julia> first(c)
(1,"e")
(1, "e")
```
"""
zip(a, b, c...) = Zip(a, zip(b, c...))
Expand Down Expand Up @@ -511,8 +511,8 @@ changes the fastest. Example:
```jldoctest
julia> collect(Iterators.product(1:2,3:5))
2×3 Array{Tuple{Int64,Int64},2}:
(1,3) (1,4) (1,5)
(2,3) (2,4) (2,5)
(1, 3) (1, 4) (1, 5)
(2, 3) (2, 4) (2, 5)
```
"""
product(a, b) = Prod2(a, b)
Expand Down Expand Up @@ -641,8 +641,8 @@ Iterate over a collection `n` elements at a time.
```jldoctest
julia> collect(Iterators.partition([1,2,3,4,5], 2))
3-element Array{Array{Int64,1},1}:
[1,2]
[3,4]
[1, 2]
[3, 4]
[5]
```
"""
Expand Down
16 changes: 7 additions & 9 deletions base/linalg/eigen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ make rows and columns more equal in norm. The default is `true` for both options

```jldoctest
julia> F = eigfact([1.0 0.0 0.0; 0.0 3.0 0.0; 0.0 0.0 18.0])
Base.LinAlg.Eigen{Float64,Float64,Array{Float64,2},Array{Float64,1}}([1.0,3.0,18.0],[1.0 0.0 0.0; 0.0 1.0 0.0; 0.0 0.0 1.0])
Base.LinAlg.Eigen{Float64,Float64,Array{Float64,2},Array{Float64,1}}([1.0, 3.0, 18.0], [1.0 0.0 0.0; 0.0 1.0 0.0; 0.0 0.0 1.0])

julia> F[:values]
3-element Array{Float64,1}:
Expand Down Expand Up @@ -122,8 +122,7 @@ The eigenvectors are returned columnwise.

```jldoctest
julia> eig([1.0 0.0 0.0; 0.0 3.0 0.0; 0.0 0.0 18.0])
([1.0,3.0,18.0],
[1.0 0.0 0.0; 0.0 1.0 0.0; 0.0 0.0 1.0])
([1.0, 3.0, 18.0], [1.0 0.0 0.0; 0.0 1.0 0.0; 0.0 0.0 1.0])
```

`eig` is a wrapper around [`eigfact`](@ref), extracting all parts of the
Expand Down Expand Up @@ -225,8 +224,8 @@ julia> A = [0 im; -1 0]
julia> eigmax(A)
ERROR: DomainError:
Stacktrace:
[1] #eigmax#38(::Bool, ::Bool, ::Function, ::Array{Complex{Int64},2}) at ./linalg/eigen.jl:235
[2] eigmax(::Array{Complex{Int64},2}) at ./linalg/eigen.jl:233
[1] #eigmax#38(::Bool, ::Bool, ::Function, ::Array{Complex{Int64},2}) at ./linalg/eigen.jl:234
[2] eigmax(::Array{Complex{Int64},2}) at ./linalg/eigen.jl:232
```
"""
function eigmax(A::Union{Number, StridedMatrix}; permute::Bool=true, scale::Bool=true)
Expand Down Expand Up @@ -267,8 +266,8 @@ julia> A = [0 im; -1 0]
julia> eigmin(A)
ERROR: DomainError:
Stacktrace:
[1] #eigmin#39(::Bool, ::Bool, ::Function, ::Array{Complex{Int64},2}) at ./linalg/eigen.jl:277
[2] eigmin(::Array{Complex{Int64},2}) at ./linalg/eigen.jl:275
[1] #eigmin#39(::Bool, ::Bool, ::Function, ::Array{Complex{Int64},2}) at ./linalg/eigen.jl:276
[2] eigmin(::Array{Complex{Int64},2}) at ./linalg/eigen.jl:274
```
"""
function eigmin(A::Union{Number, StridedMatrix}; permute::Bool=true, scale::Bool=true)
Expand Down Expand Up @@ -349,8 +348,7 @@ julia> B = [0 1; 1 0]
1 0

julia> eig(A, B)
(Complex{Float64}[0.0+1.0im,0.0-1.0im],
Complex{Float64}[0.0-1.0im 0.0+1.0im; -1.0-0.0im -1.0+0.0im])
(Complex{Float64}[0.0+1.0im, 0.0-1.0im], Complex{Float64}[0.0-1.0im 0.0+1.0im; -1.0-0.0im -1.0+0.0im])
```
"""
function eig(A::AbstractMatrix, B::AbstractMatrix)
Expand Down
7 changes: 1 addition & 6 deletions base/linalg/lu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,7 @@ julia> A = [4. 3.; 6. 3.]
6.0 3.0

julia> L, U, p = lu(A)
(
[1.0 0.0; 0.666667 1.0],

[6.0 3.0; 0.0 1.0],

[2,1])
([1.0 0.0; 0.666667 1.0], [6.0 3.0; 0.0 1.0], [2, 1])

julia> A[p, :] == L * U
true
Expand Down
2 changes: 1 addition & 1 deletion base/linalg/qr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ julia> v = [1; 2]
2

julia> w, r = qr(v)
([0.447214,0.894427],2.23606797749979)
([0.447214, 0.894427], 2.23606797749979)

julia> w*r == v
true
Expand Down
Loading