From 1d2a66fad489a1f807fba8fbe1823b1674e4e215 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Fri, 3 Feb 2017 15:22:53 +0000 Subject: [PATCH] correct all doctests to account for new whitespce printing (#20417) --- base/abstractarray.jl | 39 +++++++++---------- base/array.jl | 18 ++++----- base/broadcast.jl | 8 ++-- base/docs/helpdb/Base.jl | 14 +++---- base/expr.jl | 2 +- base/intfuncs.jl | 4 +- base/iterators.jl | 12 +++--- base/linalg/eigen.jl | 16 ++++---- base/linalg/lu.jl | 7 +--- base/linalg/qr.jl | 2 +- base/linalg/schur.jl | 9 +---- base/linalg/svd.jl | 8 +--- base/math.jl | 2 +- base/multidimensional.jl | 4 +- base/number.jl | 4 +- base/operators.jl | 8 ++-- base/path.jl | 6 +-- base/reduce.jl | 4 +- base/reflection.jl | 26 ++++++------- base/strings/util.jl | 1 - base/test.jl | 6 +-- doc/src/devdocs/types.md | 10 ++--- doc/src/manual/arrays.md | 32 +++++++-------- doc/src/manual/constructors.md | 30 +++++++------- doc/src/manual/control-flow.md | 10 ++--- doc/src/manual/dates.md | 10 ++--- doc/src/manual/faq.md | 2 +- doc/src/manual/functions.md | 36 ++++++++--------- .../integers-and-floating-point-numbers.md | 10 ++--- doc/src/manual/linear-algebra.md | 2 +- doc/src/manual/methods.md | 4 +- doc/src/manual/strings.md | 6 +-- doc/src/manual/types.md | 18 ++++----- doc/src/manual/variables-and-scoping.md | 4 +- 34 files changed, 177 insertions(+), 197 deletions(-) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index d767e9205d71e..5ca6ef34820f1 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -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 @@ -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) @@ -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))) @@ -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) @@ -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 ``` @@ -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}: @@ -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}: @@ -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}: @@ -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) @@ -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)) diff --git a/base/array.jl b/base/array.jl index 4844173a8bad2..20d9c1b70e394 100644 --- a/base/array.jl +++ b/base/array.jl @@ -1426,7 +1426,7 @@ 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}: @@ -1434,7 +1434,7 @@ julia> A = zeros(2,2) 0.0 0.0 julia> findn(A) -(Int64[],Int64[]) +(Int64[], Int64[]) ``` """ function findn(A::AbstractMatrix) @@ -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}) @@ -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) @@ -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) diff --git a/base/broadcast.jl b/base/broadcast.jl index 249c16fd5fe27..f8db6c8c0517a 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -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}: @@ -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}: diff --git a/base/docs/helpdb/Base.jl b/base/docs/helpdb/Base.jl index 945c5e960ac49..b79496acbfee0 100644 --- a/base/docs/helpdb/Base.jl +++ b/base/docs/helpdb/Base.jl @@ -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}: @@ -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) @@ -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 @@ -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 diff --git a/base/expr.jl b/base/expr.jl index 9c0bf231c99fe..51c4b68772495 100644 --- a/base/expr.jl +++ b/base/expr.jl @@ -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 diff --git a/base/intfuncs.jl b/base/intfuncs.jl index 003c5ff783a20..bba4708fbce1a 100644 --- a/base/intfuncs.jl +++ b/base/intfuncs.jl @@ -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 diff --git a/base/iterators.jl b/base/iterators.jl index 9f759ad92941d..a740e477795bc 100644 --- a/base/iterators.jl +++ b/base/iterators.jl @@ -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...)) @@ -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) @@ -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] ``` """ diff --git a/base/linalg/eigen.jl b/base/linalg/eigen.jl index 9386a7f0a65e5..423c2a224b19c 100644 --- a/base/linalg/eigen.jl +++ b/base/linalg/eigen.jl @@ -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}: @@ -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 @@ -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) @@ -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) @@ -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) diff --git a/base/linalg/lu.jl b/base/linalg/lu.jl index 501d1542c5459..d00cdf2eddead 100644 --- a/base/linalg/lu.jl +++ b/base/linalg/lu.jl @@ -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 diff --git a/base/linalg/qr.jl b/base/linalg/qr.jl index c27e8522a6e0f..2a62dec805da1 100644 --- a/base/linalg/qr.jl +++ b/base/linalg/qr.jl @@ -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 diff --git a/base/linalg/schur.jl b/base/linalg/schur.jl index cfd75d203f763..63f04c9784f57 100644 --- a/base/linalg/schur.jl +++ b/base/linalg/schur.jl @@ -34,7 +34,7 @@ julia> A = [-2. 1. 3.; 2. 1. -1.; -7. 2. 7.] -7.0 2.0 7.0 julia> F = schurfact(A) -Base.LinAlg.Schur{Float64,Array{Float64,2}}([2.0 0.801792 6.63509; -8.55988e-11 2.0 8.08286; 0.0 0.0 1.99999],[0.577351 0.154299 -0.801784; 0.577346 -0.77152 0.267262; 0.577354 0.617211 0.534522],Complex{Float64}[2.0+8.28447e-6im,2.0-8.28447e-6im,1.99999+0.0im]) +Base.LinAlg.Schur{Float64,Array{Float64,2}}([2.0 0.801792 6.63509; -8.55988e-11 2.0 8.08286; 0.0 0.0 1.99999], [0.577351 0.154299 -0.801784; 0.577346 -0.77152 0.267262; 0.577354 0.617211 0.534522], Complex{Float64}[2.0+8.28447e-6im, 2.0-8.28447e-6im, 1.99999+0.0im]) julia> F[:vectors] * F[:Schur] * F[:vectors]' 3×3 Array{Float64,2}: @@ -80,12 +80,7 @@ julia> A = [-2. 1. 3.; 2. 1. -1.; -7. 2. 7.] -7.0 2.0 7.0 julia> T, Z, lambda = schur(A) -( -[2.0 0.801792 6.63509; -8.55988e-11 2.0 8.08286; 0.0 0.0 1.99999], - -[0.577351 0.154299 -0.801784; 0.577346 -0.77152 0.267262; 0.577354 0.617211 0.534522], - -Complex{Float64}[2.0+8.28447e-6im,2.0-8.28447e-6im,1.99999+0.0im]) +([2.0 0.801792 6.63509; -8.55988e-11 2.0 8.08286; 0.0 0.0 1.99999], [0.577351 0.154299 -0.801784; 0.577346 -0.77152 0.267262; 0.577354 0.617211 0.534522], Complex{Float64}[2.0+8.28447e-6im, 2.0-8.28447e-6im, 1.99999+0.0im]) julia> Z * T * Z' 3×3 Array{Float64,2}: diff --git a/base/linalg/svd.jl b/base/linalg/svd.jl index f0ee0d3f38c8d..7c7183f720ce0 100644 --- a/base/linalg/svd.jl +++ b/base/linalg/svd.jl @@ -52,7 +52,7 @@ julia> A = [1. 0. 0. 0. 2.; 0. 0. 3. 0. 0.; 0. 0. 0. 0. 0.; 0. 2. 0. 0. 0.] 0.0 2.0 0.0 0.0 0.0 julia> F = svdfact(A) -Base.LinAlg.SVD{Float64,Float64,Array{Float64,2}}([0.0 1.0 0.0 0.0; 1.0 0.0 0.0 0.0; 0.0 0.0 0.0 -1.0; 0.0 0.0 1.0 0.0],[3.0,2.23607,2.0,0.0],[-0.0 0.0 … -0.0 0.0; 0.447214 0.0 … 0.0 0.894427; -0.0 1.0 … -0.0 0.0; 0.0 0.0 … 1.0 0.0]) +Base.LinAlg.SVD{Float64,Float64,Array{Float64,2}}([0.0 1.0 0.0 0.0; 1.0 0.0 0.0 0.0; 0.0 0.0 0.0 -1.0; 0.0 0.0 1.0 0.0], [3.0, 2.23607, 2.0, 0.0], [-0.0 0.0 … -0.0 0.0; 0.447214 0.0 … 0.0 0.894427; -0.0 1.0 … -0.0 0.0; 0.0 0.0 … 1.0 0.0]) julia> F[:U] * diagm(F[:S]) * F[:Vt] 4×5 Array{Float64,2}: @@ -94,11 +94,7 @@ julia> A = [1. 0. 0. 0. 2.; 0. 0. 3. 0. 0.; 0. 0. 0. 0. 0.; 0. 2. 0. 0. 0.] 0.0 2.0 0.0 0.0 0.0 julia> U, S, V = svd(A) -( -[0.0 1.0 0.0 0.0; 1.0 0.0 0.0 0.0; 0.0 0.0 0.0 -1.0; 0.0 0.0 1.0 0.0], - -[3.0,2.23607,2.0,0.0], -[-0.0 0.447214 -0.0 0.0; 0.0 0.0 1.0 0.0; … ; -0.0 0.0 -0.0 1.0; 0.0 0.894427 0.0 0.0]) +([0.0 1.0 0.0 0.0; 1.0 0.0 0.0 0.0; 0.0 0.0 0.0 -1.0; 0.0 0.0 1.0 0.0], [3.0, 2.23607, 2.0, 0.0], [-0.0 0.447214 -0.0 0.0; 0.0 0.0 1.0 0.0; … ; -0.0 0.0 -0.0 1.0; 0.0 0.894427 0.0 0.0]) julia> U*diagm(S)*V' 4×5 Array{Float64,2}: diff --git a/base/math.jl b/base/math.jl index 523f7fec89299..0cd685425a659 100644 --- a/base/math.jl +++ b/base/math.jl @@ -660,7 +660,7 @@ have the same sign as the argument. ```jldoctest julia> modf(3.5) -(0.5,3.0) +(0.5, 3.0) ``` """ modf(x) = rem(x,one(x)), trunc(x) diff --git a/base/multidimensional.jl b/base/multidimensional.jl index ffe1b10d7a7af..b7b305dd621db 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -1300,10 +1300,10 @@ julia> A = reshape(collect(1:2:16), (2,2,2)) julia> extrema(A, (1,2)) 1×1×2 Array{Tuple{Int64,Int64},3}: [:, :, 1] = - (1,7) + (1, 7) [:, :, 2] = - (9,15) + (9, 15) ``` """ function extrema(A::AbstractArray, dims) diff --git a/base/number.jl b/base/number.jl index 5648ed651a944..e2b04c633199a 100644 --- a/base/number.jl +++ b/base/number.jl @@ -55,10 +55,10 @@ The quotient and remainder from Euclidean division. Equivalent to `(div(x,y), re ```jldoctest julia> divrem(3,7) -(0,3) +(0, 3) julia> divrem(7,3) -(2,1) +(2, 1) ``` """ divrem(x,y) = (div(x,y),rem(x,y)) diff --git a/base/operators.jl b/base/operators.jl index 8ff256cf58ac7..873da59e9830b 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -211,7 +211,7 @@ Return `(min(x,y), max(x,y))`. See also: [`extrema`](@ref) that returns `(minimu ```jldoctest julia> minmax('c','b') -('b','c') +('b', 'c') ``` """ minmax(x,y) = y < x ? (y, x) : (x, y) @@ -744,10 +744,10 @@ julia> a = ones(3,4,1,1,1); julia> b = ones(3,4); julia> promote_shape(a,b) -(Base.OneTo(3),Base.OneTo(4),Base.OneTo(1),Base.OneTo(1),Base.OneTo(1)) +(Base.OneTo(3), Base.OneTo(4), Base.OneTo(1), Base.OneTo(1), Base.OneTo(1)) -julia> promote_shape((2,3,1,4), (2,3,1,4,1)) -(2,3,1,4,1) +julia> promote_shape((2,3,1,4), (2, 3, 1, 4, 1)) +(2, 3, 1, 4, 1) ``` """ function promote_shape(a::Dims, b::Dims) diff --git a/base/path.jl b/base/path.jl index 9b854bdbb4b5e..6b04246a5f777 100644 --- a/base/path.jl +++ b/base/path.jl @@ -110,7 +110,7 @@ Split a path into a tuple of the directory name and file name. ```jldoctest julia> splitdir("/home/myuser") -("/home","myuser") +("/home", "myuser") ``` """ function splitdir(path::String) @@ -154,10 +154,10 @@ unmodified and the empty string. ```jldoctest julia> splitext("/home/myuser/example.jl") -("/home/myuser/example",".jl") +("/home/myuser/example", ".jl") julia> splitext("/home/myuser/example") -("/home/myuser/example","") +("/home/myuser/example", "") ``` """ function splitext(path::String) diff --git a/base/reduce.jl b/base/reduce.jl index d943b60370a37..620ab55e9c5bc 100644 --- a/base/reduce.jl +++ b/base/reduce.jl @@ -475,10 +475,10 @@ Compute both the minimum and maximum element in a single pass, and return them a ```jldoctest julia> extrema(2:10) -(2,10) +(2, 10) julia> extrema([9,pi,4.5]) -(3.141592653589793,9.0) +(3.141592653589793, 9.0) ``` """ function extrema(itr) diff --git a/base/reflection.jl b/base/reflection.jl index 9c791c981bb09..41c15cee63b7b 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -43,7 +43,7 @@ Get the fully-qualified name of a module as a tuple of symbols. For example, ```jldoctest julia> fullname(Base.Pkg) -(:Base,:Pkg) +(:Base, :Pkg) julia> fullname(Main) () @@ -286,18 +286,18 @@ julia> structinfo(T) = [(fieldoffset(T,i), fieldname(T,i), fieldtype(T,i)) for i julia> structinfo(Base.Filesystem.StatStruct) 12-element Array{Tuple{UInt64,Symbol,DataType},1}: - (0x0000000000000000,:device,UInt64) - (0x0000000000000008,:inode,UInt64) - (0x0000000000000010,:mode,UInt64) - (0x0000000000000018,:nlink,Int64) - (0x0000000000000020,:uid,UInt64) - (0x0000000000000028,:gid,UInt64) - (0x0000000000000030,:rdev,UInt64) - (0x0000000000000038,:size,Int64) - (0x0000000000000040,:blksize,Int64) - (0x0000000000000048,:blocks,Int64) - (0x0000000000000050,:mtime,Float64) - (0x0000000000000058,:ctime,Float64) + (0x0000000000000000, :device, UInt64) + (0x0000000000000008, :inode, UInt64) + (0x0000000000000010, :mode, UInt64) + (0x0000000000000018, :nlink, Int64) + (0x0000000000000020, :uid, UInt64) + (0x0000000000000028, :gid, UInt64) + (0x0000000000000030, :rdev, UInt64) + (0x0000000000000038, :size, Int64) + (0x0000000000000040, :blksize, Int64) + (0x0000000000000048, :blocks, Int64) + (0x0000000000000050, :mtime, Float64) + (0x0000000000000058, :ctime, Float64) ``` """ fieldoffset(x::DataType, idx::Integer) = (@_pure_meta; ccall(:jl_get_field_offset, Csize_t, (Any, Cint), x, idx)) diff --git a/base/strings/util.jl b/base/strings/util.jl index ddc1c92fe3572..905bc0db678b8 100644 --- a/base/strings/util.jl +++ b/base/strings/util.jl @@ -483,7 +483,6 @@ throwing an `ArgumentError` indicating the position of the first non-ASCII byte. ```jldoctest julia> ascii("abcdeγfgh") -julia> ascii("abcdeγfgh") ERROR: ArgumentError: invalid ASCII at index 6 in "abcdeγfgh" Stacktrace: [1] ascii(::String) at ./strings/util.jl:473 diff --git a/base/test.jl b/base/test.jl index f21b8a0c2f830..30f2b4635ba50 100644 --- a/base/test.jl +++ b/base/test.jl @@ -1040,14 +1040,14 @@ Variables: Body: begin - unless (Base.slt_int)(1,b::Int64)::Bool goto 3 + unless (Base.slt_int)(1, b::Int64)::Bool goto 3 return 1 3: return 1.0 - end::UNION{FLOAT64,INT64} + end::UNION{FLOAT64, INT64} julia> @inferred f(1,2,3) -ERROR: return type Int64 does not match inferred return type Union{Float64,Int64} +ERROR: return type Int64 does not match inferred return type Union{Float64, Int64} Stacktrace: [1] error(::String) at ./error.jl:21 diff --git a/doc/src/devdocs/types.md b/doc/src/devdocs/types.md index 4df91a585abd4..2b86fb6becdcf 100644 --- a/doc/src/devdocs/types.md +++ b/doc/src/devdocs/types.md @@ -28,7 +28,7 @@ julia> typeintersect(Int, Float64) Union{} julia> Union{Int, Float64} -Union{Float64,Int64} +Union{Float64, Int64} julia> typejoin(Int, Float64) Real @@ -37,7 +37,7 @@ julia> typeintersect(Signed, Union{UInt8, Int8}) Int8 julia> Union{Signed, Union{UInt8, Int8}} -Union{Signed,UInt8} +Union{Signed, UInt8} julia> typejoin(Signed, Union{UInt8, Int8}) Integer @@ -46,7 +46,7 @@ julia> typeintersect(Tuple{Integer,Float64}, Tuple{Int,Real}) Tuple{Int64,Float64} julia> Union{Tuple{Integer,Float64}, Tuple{Int,Real}} -Union{Tuple{Int64,Real},Tuple{Integer,Float64}} +Union{Tuple{Int64,Real}, Tuple{Integer,Float64}} julia> typejoin(Tuple{Integer,Float64}, Tuple{Int,Real}) Tuple{Integer,Real} @@ -157,7 +157,7 @@ The following two [`Array`](@ref) types are functionally equivalent, yet print d ```jldoctest julia> TV, NV = TypeVar(:T), TypeVar(:N) -(T,N) +(T, N) julia> Array Array @@ -238,7 +238,7 @@ julia> MyType{Float32, 5} MyType{Float32,5} julia> MyType.body.body.name.cache -svec(MyType{Float32,5},MyType{Int64,2},#undef,#undef,#undef,#undef,#undef,#undef) +svec(MyType{Float32,5}, MyType{Int64,2}, #undef, #undef, #undef, #undef, #undef, #undef) ``` (The cache is pre-allocated to have length 8, but only the first two entries are populated.) Consequently, diff --git a/doc/src/manual/arrays.md b/doc/src/manual/arrays.md index 0994e52d081ce..f413d62ae9dc1 100644 --- a/doc/src/manual/arrays.md +++ b/doc/src/manual/arrays.md @@ -193,8 +193,8 @@ us add a third argument to `map`: ```jldoctest julia> map(tuple, (1/(i+j) for i=1:2, j=1:2), [1 3; 2 4]) 2×2 Array{Tuple{Float64,Int64},2}: - (0.5,1) (0.333333,3) - (0.333333,2) (0.25,4) + (0.5, 1) (0.333333, 3) + (0.333333, 2) (0.25, 4) ``` Ranges in generators and comprehensions can depend on previous ranges by writing multiple `for` @@ -203,12 +203,12 @@ keywords: ```jldoctest julia> [(i,j) for i=1:3 for j=1:i] 6-element Array{Tuple{Int64,Int64},1}: - (1,1) - (2,1) - (2,2) - (3,1) - (3,2) - (3,3) + (1, 1) + (2, 1) + (2, 2) + (3, 1) + (3, 2) + (3, 3) ``` In such cases, the result is always 1-d. @@ -218,8 +218,8 @@ Generated values can be filtered using the `if` keyword: ```jldoctest julia> [(i,j) for i=1:3 for j=1:i if i+j == 4] 2-element Array{Tuple{Int64,Int64},1}: - (2,2) - (3,1) + (2, 2) + (3, 1) ``` ### [Indexing](@id man-array-indexing) @@ -497,12 +497,12 @@ julia> B = view(A, 1:3, 2:3); julia> for i in eachindex(B) @show i end -i = CartesianIndex{2}((1,1)) -i = CartesianIndex{2}((2,1)) -i = CartesianIndex{2}((3,1)) -i = CartesianIndex{2}((1,2)) -i = CartesianIndex{2}((2,2)) -i = CartesianIndex{2}((3,2)) +i = CartesianIndex{2}((1, 1)) +i = CartesianIndex{2}((2, 1)) +i = CartesianIndex{2}((3, 1)) +i = CartesianIndex{2}((1, 2)) +i = CartesianIndex{2}((2, 2)) +i = CartesianIndex{2}((3, 2)) ``` In contrast with `for i = 1:length(A)`, iterating with `eachindex` provides an efficient way to diff --git a/doc/src/manual/constructors.md b/doc/src/manual/constructors.md index e360200de2b21..ef5479a96ab25 100644 --- a/doc/src/manual/constructors.md +++ b/doc/src/manual/constructors.md @@ -11,8 +11,8 @@ julia> type Foo baz end -julia> foo = Foo(1,2) -Foo(1,2) +julia> foo = Foo(1, 2) +Foo(1, 2) julia> foo.bar 1 @@ -51,7 +51,7 @@ julia> Foo(x) = Foo(x,x) Foo julia> Foo(1) -Foo(1,1) +Foo(1, 1) ``` You could also add a zero-argument `Foo` constructor method that supplies default values for both @@ -62,7 +62,7 @@ julia> Foo() = Foo(0) Foo julia> Foo() -Foo(0,0) +Foo(0, 0) ``` Here the zero-argument constructor method calls the single-argument constructor method, which @@ -99,8 +99,8 @@ julia> type OrderedPair Now `OrderedPair` objects can only be constructed such that `x <= y`: ```jldoctest pairtype -julia> OrderedPair(1,2) -OrderedPair(1,2) +julia> OrderedPair(1, 2) +OrderedPair(1, 2) julia> OrderedPair(2,1) ERROR: out of order @@ -288,10 +288,10 @@ julia> type Point{T<:Real} end julia> Point(1,2) ## implicit T ## -Point{Int64}(1,2) +Point{Int64}(1, 2) julia> Point(1.0,2.5) ## implicit T ## -Point{Float64}(1.0,2.5) +Point{Float64}(1.0, 2.5) julia> Point(1,2.5) ## implicit T ## ERROR: MethodError: no method matching Point(::Int64, ::Float64) @@ -299,8 +299,8 @@ Closest candidates are: Point{T}(::Any) at sysimg.jl:24 Point{T<:Real}(::T<:Real, !Matched::T<:Real) at none:2 -julia> Point{Int64}(1,2) ## explicit T ## -Point{Int64}(1,2) +julia> Point{Int64}(1, 2) ## explicit T ## +Point{Int64}(1, 2) julia> Point{Int64}(1.0,2.5) ## explicit T ## ERROR: InexactError() @@ -368,7 +368,7 @@ successfully creates a point of type `Point{Float64}`: ```jldoctest parametric2 julia> Point(1,2.5) -Point{Float64}(1.0,2.5) +Point{Float64}(1.0, 2.5) julia> typeof(ans) Point{Float64} @@ -398,13 +398,13 @@ numeric operators like [`+`](@ref) do, and works for all kinds of real numbers: ```jldoctest parametric2 julia> Point(1.5,2) -Point{Float64}(1.5,2.0) +Point{Float64}(1.5, 2.0) julia> Point(1,1//2) -Point{Rational{Int64}}(1//1,1//2) +Point{Rational{Int64}}(1//1, 1//2) julia> Point(1.0,1//2) -Point{Float64}(1.0,0.5) +Point{Float64}(1.0, 0.5) ``` Thus, while the implicit type parameter constructors provided by default in Julia are fairly strict, @@ -555,7 +555,7 @@ julia> type SummedArray{T<:Number,S<:Number} end julia> SummedArray(Int32[1; 2; 3], Int32(6)) -SummedArray{Int32,Int32}(Int32[1,2,3],6) +SummedArray{Int32,Int32}(Int32[1, 2, 3], 6) ``` The problem is that we want `S` to be a larger type than `T`, so that we can sum many elements diff --git a/doc/src/manual/control-flow.md b/doc/src/manual/control-flow.md index a4a34cf4dfac6..eec97d5df6d06 100644 --- a/doc/src/manual/control-flow.md +++ b/doc/src/manual/control-flow.md @@ -363,7 +363,7 @@ be evaluated and returned depending on the preceding conditionals: ```jldoctest julia> true && (x = (1, 2, 3)) -(1,2,3) +(1, 2, 3) julia> false && (x = (1, 2, 3)) false @@ -516,10 +516,10 @@ of its iterables: julia> for i = 1:2, j = 3:4 println((i, j)) end -(1,3) -(1,4) -(2,3) -(2,4) +(1, 3) +(1, 4) +(2, 3) +(2, 4) ``` A `break` statement inside such a loop exits the entire nest of loops, not just the inner one. diff --git a/doc/src/manual/dates.md b/doc/src/manual/dates.md index 9ea0a41b40668..dc72256fdf0ed 100644 --- a/doc/src/manual/dates.md +++ b/doc/src/manual/dates.md @@ -194,7 +194,7 @@ parts or fields can be retrieved through accessor functions. The lowercase acces field as an integer: ```jldoctest tdate -julia> t = Date(2014,1,31) +julia> t = Date(2014, 1, 31) 2014-01-31 julia> Dates.year(t) @@ -225,13 +225,13 @@ needed at the same time: ```jldoctest tdate julia> Dates.yearmonth(t) -(2014,1) +(2014, 1) julia> Dates.monthday(t) -(1,31) +(1, 31) julia> Dates.yearmonthday(t) -(2014,1,31) +(2014, 1, 31) ``` One may also access the underlying `UTInstant` or integer value: @@ -256,7 +256,7 @@ Query functions provide calendrical information about a [`TimeType`](@ref). They about the day of the week: ```jldoctest tdate2 -julia> t = Date(2014,1,31) +julia> t = Date(2014, 1, 31) 2014-01-31 julia> Dates.dayofweek(t) diff --git a/doc/src/manual/faq.md b/doc/src/manual/faq.md index 699c0a34da5ff..f20ed7204ca5e 100644 --- a/doc/src/manual/faq.md +++ b/doc/src/manual/faq.md @@ -677,7 +677,7 @@ You can lock your writes with a `ReentrantLock` like this: ```jldoctest julia> l = ReentrantLock() -ReentrantLock(Nullable{Task}(),Condition(Any[]),0) +ReentrantLock(Nullable{Task}(), Condition(Any[]), 0) julia> @sync for i in 1:3 @async begin diff --git a/doc/src/manual/functions.md b/doc/src/manual/functions.md index f44d4e30f0d86..1793befa0beed 100644 --- a/doc/src/manual/functions.md +++ b/doc/src/manual/functions.md @@ -243,7 +243,7 @@ see the tuple returned: ```jldoctest foofunc julia> foo(2,3) -(5,6) +(5, 6) ``` A typical usage of such a pair of return values, however, extracts each value into a variable. @@ -251,7 +251,7 @@ Julia supports simple tuple "destructuring" that facilitates this: ```jldoctest foofunc julia> x, y = foo(2,3) -(5,6) +(5, 6) julia> x 5 @@ -287,16 +287,16 @@ two arguments: ```jldoctest barfunc julia> bar(1,2) -(1,2,()) +(1, 2, ()) julia> bar(1,2,3) -(1,2,(3,)) +(1, 2, (3,)) -julia> bar(1,2,3,4) -(1,2,(3,4)) +julia> bar(1, 2, 3, 4) +(1, 2, (3, 4)) julia> bar(1,2,3,4,5,6) -(1,2,(3,4,5,6)) +(1, 2, (3, 4, 5, 6)) ``` In all these cases, `x` is bound to a tuple of the trailing values passed to `bar`. @@ -309,28 +309,28 @@ into a function call as individual arguments. To do this, one also uses `...` bu call instead: ```jldoctest barfunc -julia> x = (3,4) -(3,4) +julia> x = (3, 4) +(3, 4) julia> bar(1,2,x...) -(1,2,(3,4)) +(1, 2, (3, 4)) ``` In this case a tuple of values is spliced into a varargs call precisely where the variable number of arguments go. This need not be the case, however: ```jldoctest barfunc -julia> x = (2,3,4) -(2,3,4) +julia> x = (2, 3, 4) +(2, 3, 4) julia> bar(1,x...) -(1,2,(3,4)) +(1, 2, (3, 4)) -julia> x = (1,2,3,4) -(1,2,3,4) +julia> x = (1, 2, 3, 4) +(1, 2, 3, 4) julia> bar(x...) -(1,2,(3,4)) +(1, 2, (3, 4)) ``` Furthermore, the iterable object spliced into a function call need not be a tuple: @@ -342,7 +342,7 @@ julia> x = [3,4] 4 julia> bar(1,2,x...) -(1,2,(3,4)) +(1, 2, (3, 4)) julia> x = [1,2,3,4] 4-element Array{Int64,1}: @@ -352,7 +352,7 @@ julia> x = [1,2,3,4] 4 julia> bar(x...) -(1,2,(3,4)) +(1, 2, (3, 4)) ``` Also, the function that arguments are spliced into need not be a varargs function (although it diff --git a/doc/src/manual/integers-and-floating-point-numbers.md b/doc/src/manual/integers-and-floating-point-numbers.md index 4a5297257b832..6d7d8aaeb96da 100644 --- a/doc/src/manual/integers-and-floating-point-numbers.md +++ b/doc/src/manual/integers-and-floating-point-numbers.md @@ -166,7 +166,7 @@ by the [`typemin()`](@ref) and [`typemax()`](@ref) functions: ```jldoctest julia> (typemin(Int32), typemax(Int32)) -(-2147483648,2147483647) +(-2147483648, 2147483647) julia> for T in [Int8,Int16,Int32,Int64,Int128,UInt8,UInt16,UInt32,UInt64,UInt128] println("$(lpad(T,7)): [$(typemin(T)),$(typemax(T))]") @@ -298,7 +298,7 @@ The underscore `_` can be used as digit separator: ```jldoctest julia> 10_000, 0.000_000_005, 0xdead_beef, 0b1011_0010 -(10000,5.0e-9,0xdeadbeef,0xb2) +(10000, 5.0e-9, 0xdeadbeef, 0xb2) ``` ### Floating-point zero @@ -375,13 +375,13 @@ The [`typemin()`](@ref) and [`typemax()`](@ref) functions also apply to floating ```jldoctest julia> (typemin(Float16),typemax(Float16)) -(-Inf16,Inf16) +(-Inf16, Inf16) julia> (typemin(Float32),typemax(Float32)) -(-Inf32,Inf32) +(-Inf32, Inf32) julia> (typemin(Float64),typemax(Float64)) -(-Inf,Inf) +(-Inf, Inf) ``` ### Machine epsilon diff --git a/doc/src/manual/linear-algebra.md b/doc/src/manual/linear-algebra.md index b6e38fe5d651b..af5ff9a2766f4 100644 --- a/doc/src/manual/linear-algebra.md +++ b/doc/src/manual/linear-algebra.md @@ -75,7 +75,7 @@ julia> B = [1.5 2 -4; 2 -1 -3; -4 -3 5] -4.0 -3.0 5.0 julia> factorize(B) -Base.LinAlg.BunchKaufman{Float64,Array{Float64,2}}([-1.64286 0.142857 -0.8; 2.0 -2.8 -0.6; -4.0 -3.0 5.0],[1,2,3],'U',true,false,0) +Base.LinAlg.BunchKaufman{Float64,Array{Float64,2}}([-1.64286 0.142857 -0.8; 2.0 -2.8 -0.6; -4.0 -3.0 5.0], [1, 2, 3], 'U', true, false, 0) ``` Here, Julia was able to detect that `B` is in fact symmetric, and used a more appropriate factorization. diff --git a/doc/src/manual/methods.md b/doc/src/manual/methods.md index 54ed4c4029982..ec04a1eba4756 100644 --- a/doc/src/manual/methods.md +++ b/doc/src/manual/methods.md @@ -522,7 +522,7 @@ Closest candidates are: bar(::Any, ::Any, ::Any, !Matched::Any) at none:1 julia> bar(1,2,3,4) -(1,2,(3,4)) +(1, 2, (3, 4)) julia> bar(1,2,3,4,5) ERROR: MethodError: no method matching bar(::Int64, ::Int64, ::Int64, ::Int64, ::Int64) @@ -599,7 +599,7 @@ refer to the object that was called. A `Polynomial` can be used as follows: ```jldoctest polynomial julia> p = Polynomial([1,10,100]) -Polynomial{Int64}([1,10,100]) +Polynomial{Int64}([1, 10, 100]) julia> p(3) 931 diff --git a/doc/src/manual/strings.md b/doc/src/manual/strings.md index 1c888a18b980e..66ded3d982b04 100644 --- a/doc/src/manual/strings.md +++ b/doc/src/manual/strings.md @@ -389,7 +389,7 @@ julia> v = [1,2,3] 3 julia> "v: $v" -"v: [1,2,3]" +"v: [1, 2, 3]" ``` [`string()`](@ref) is the identity for `AbstractString` and `Char` values, so these are interpolated @@ -652,7 +652,7 @@ julia> m.match "acd" julia> m.captures -3-element Array{Union{SubString{String},Void},1}: +3-element Array{Union{SubString{String}, Void},1}: "a" "c" "d" @@ -673,7 +673,7 @@ julia> m.match "ad" julia> m.captures -3-element Array{Union{SubString{String},Void},1}: +3-element Array{Union{SubString{String}, Void},1}: "a" nothing "d" diff --git a/doc/src/manual/types.md b/doc/src/manual/types.md index e4289d906a1ca..4b1c1f41dcbb3 100644 --- a/doc/src/manual/types.md +++ b/doc/src/manual/types.md @@ -323,7 +323,7 @@ to values for its fields: ```jldoctest footype julia> foo = Foo("Hello, world.", 23, 1.5) -Foo("Hello, world.",23,1.5) +Foo("Hello, world.", 23, 1.5) julia> typeof(foo) Foo @@ -476,7 +476,7 @@ argument types, constructed using the special `Union` function: ```jldoctest julia> IntOrString = Union{Int,AbstractString} -Union{AbstractString,Int64} +Union{AbstractString, Int64} julia> 1 :: IntOrString 1 @@ -485,7 +485,7 @@ julia> "Hello!" :: IntOrString "Hello!" julia> 1.0 :: IntOrString -ERROR: TypeError: typeassert: expected Union{AbstractString,Int64}, got Float64 +ERROR: TypeError: typeassert: expected Union{AbstractString, Int64}, got Float64 ``` The compilers for many languages have an internal union construct for reasoning about types; Julia @@ -624,8 +624,8 @@ Since the type `Point{Float64}` is a concrete type equivalent to `Point` declare in place of `T`, it can be applied as a constructor accordingly: ```jldoctest pointtype -julia> Point{Float64}(1.0,2.0) -Point{Float64}(1.0,2.0) +julia> Point{Float64}(1.0, 2.0) +Point{Float64}(1.0, 2.0) julia> typeof(ans) Point{Float64} @@ -655,13 +655,13 @@ of the parameter type `T` is unambiguous: ```jldoctest pointtype julia> Point(1.0,2.0) -Point{Float64}(1.0,2.0) +Point{Float64}(1.0, 2.0) julia> typeof(ans) Point{Float64} julia> Point(1,2) -Point{Int64}(1,2) +Point{Int64}(1, 2) julia> typeof(ans) Point{Int64} @@ -1127,7 +1127,7 @@ is raised: ```jldoctest julia> supertype(Union{Float64,Int64}) -ERROR: MethodError: no method matching supertype(::Type{Union{Float64,Int64}}) +ERROR: MethodError: no method matching supertype(::Type{Union{Float64, Int64}}) Closest candidates are: supertype(!Matched::DataType) at operators.jl:27 supertype(!Matched::UnionAll) at operators.jl:32 @@ -1308,7 +1308,7 @@ julia> x2 = Nullable(1.0) Nullable{Float64}(1.0) julia> x3 = Nullable([1, 2, 3]) -Nullable{Array{Int64,1}}([1,2,3]) +Nullable{Array{Int64,1}}([1, 2, 3]) ``` Note the core distinction between these two ways of constructing a `Nullable` object: diff --git a/doc/src/manual/variables-and-scoping.md b/doc/src/manual/variables-and-scoping.md index 305d924c13aaa..ba6b85c1046e8 100644 --- a/doc/src/manual/variables-and-scoping.md +++ b/doc/src/manual/variables-and-scoping.md @@ -245,7 +245,7 @@ julia> baz() 22 julia> x, y -(1,2) +(1, 2) ``` The distinction between inheriting global and local variables for assignment can lead to some @@ -269,7 +269,7 @@ julia> quz() 14 julia> x, y -(1,2) +(1, 2) ``` Note that above subtlety does not pertain to type and macro definitions as they can only appear