diff --git a/base/LineEdit.jl b/base/LineEdit.jl index 39d3b7dc935c2..28277556539e5 100644 --- a/base/LineEdit.jl +++ b/base/LineEdit.jl @@ -880,7 +880,7 @@ end # source is the keymap specified by the user (with normalized keys) function keymap_merge(target,source) ret = copy(target) - direct_keys = filter((k,v) -> isa(v, Union(Function, KeyAlias, Void)), source) + direct_keys = filter((k,v) -> isa(v, Union{Function, KeyAlias, Void}), source) # first direct entries for key in keys(direct_keys) add_nested_key!(ret, key, source[key]; override = true) @@ -890,7 +890,7 @@ function keymap_merge(target,source) # We first resolve redirects in the source value = source[key] visited = Array(Any,0) - while isa(value, Union(Char,AbstractString)) + while isa(value, Union{Char,AbstractString}) value = normalize_key(value) if value in visited error("Eager redirection cycle detected for key " * escape_string(key)) @@ -902,7 +902,7 @@ function keymap_merge(target,source) value = source[value] end - if isa(value, Union(Char,AbstractString)) + if isa(value, Union{Char,AbstractString}) value = getEntry(ret, value) if value === nothing error("Could not find redirected value " * escape_string(source[key])) @@ -1265,8 +1265,8 @@ function setup_search_keymap(hp) (p, skeymap) end -keymap(state, p::Union(HistoryPrompt,PrefixHistoryPrompt)) = p.keymap_dict -keymap_data(state, ::Union(HistoryPrompt, PrefixHistoryPrompt)) = state +keymap(state, p::Union{HistoryPrompt,PrefixHistoryPrompt}) = p.keymap_dict +keymap_data(state, ::Union{HistoryPrompt, PrefixHistoryPrompt}) = state Base.isempty(s::PromptState) = s.input_buffer.size == 0 diff --git a/base/REPL.jl b/base/REPL.jl index c0c04ac75c9bc..ac293dd0ad700 100644 --- a/base/REPL.jl +++ b/base/REPL.jl @@ -380,7 +380,7 @@ function add_history(hist::REPLHistoryProvider, s) flush(hist.history_file) end -function history_move(s::Union(LineEdit.MIState,LineEdit.PrefixSearchState), hist::REPLHistoryProvider, idx::Int, save_idx::Int = hist.cur_idx) +function history_move(s::Union{LineEdit.MIState,LineEdit.PrefixSearchState}, hist::REPLHistoryProvider, idx::Int, save_idx::Int = hist.cur_idx) max_idx = length(hist.history) + 1 @assert 1 <= hist.cur_idx <= max_idx (1 <= idx <= max_idx) || return :none diff --git a/base/REPLCompletions.jl b/base/REPLCompletions.jl index 33741029a68ba..2c24a22c600bb 100644 --- a/base/REPLCompletions.jl +++ b/base/REPLCompletions.jl @@ -26,7 +26,7 @@ function complete_symbol(sym, ffunc) mod = context_module lookup_module = true - t = Union() + t = Union{} for name in strs[1:(end-1)] s = symbol(name) if lookup_module @@ -237,7 +237,7 @@ function complete_methods(ex_org::Expr) t_in = Tuple{args_ex...} # Input types for method in methods(func) # Check if the method's type signature intersects the input types - typeintersect(Tuple{method.sig.parameters[1 : min(length(args_ex), end)]...}, t_in) != Union() && + typeintersect(Tuple{method.sig.parameters[1 : min(length(args_ex), end)]...}, t_in) != Union{} && push!(out,string(method)) end return out diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 394fbb205607e..55ab3c85c02d6 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -4,8 +4,8 @@ typealias AbstractVector{T} AbstractArray{T,1} typealias AbstractMatrix{T} AbstractArray{T,2} -typealias AbstractVecOrMat{T} Union(AbstractVector{T}, AbstractMatrix{T}) -typealias RangeIndex Union(Int, Range{Int}, UnitRange{Int}, Colon) +typealias AbstractVecOrMat{T} Union{AbstractVector{T}, AbstractMatrix{T}} +typealias RangeIndex Union{Int, Range{Int}, UnitRange{Int}, Colon} ## Basic functions ## @@ -151,15 +151,15 @@ throw_boundserror(A, I) = (@_noinline_meta; throw(BoundsError(A, I))) checkbounds(A::AbstractArray, I::AbstractArray{Bool}) = size(A) == size(I) || throw_boundserror(A, I) checkbounds(A::AbstractArray, I::AbstractVector{Bool}) = length(A) == length(I) || throw_boundserror(A, I) checkbounds(A::AbstractArray, I) = (@_inline_meta; _checkbounds(length(A), I) || throw_boundserror(A, I)) -function checkbounds(A::AbstractMatrix, I::Union(Real,AbstractArray,Colon), J::Union(Real,AbstractArray,Colon)) +function checkbounds(A::AbstractMatrix, I::Union{Real,AbstractArray,Colon}, J::Union{Real,AbstractArray,Colon}) @_inline_meta (_checkbounds(size(A,1), I) && _checkbounds(size(A,2), J)) || throw_boundserror(A, (I, J)) end -function checkbounds(A::AbstractArray, I::Union(Real,AbstractArray,Colon), J::Union(Real,AbstractArray,Colon)) +function checkbounds(A::AbstractArray, I::Union{Real,AbstractArray,Colon}, J::Union{Real,AbstractArray,Colon}) @_inline_meta (_checkbounds(size(A,1), I) && _checkbounds(trailingsize(A,Val{2}), J)) || throw_boundserror(A, (I, J)) end -@generated function checkbounds(A::AbstractArray, I::Union(Real,AbstractArray,Colon)...) +@generated function checkbounds(A::AbstractArray, I::Union{Real,AbstractArray,Colon}...) meta = Expr(:meta, :inline) N = length(I) args = Expr[:(_checkbounds(size(A,$dim), I[$dim]) || throw_boundserror(A, I)) for dim in 1:N-1] @@ -599,13 +599,13 @@ end ## get (getindex with a default value) ## -typealias RangeVecIntList{A<:AbstractVector{Int}} Union(Tuple{Vararg{Union(Range, AbstractVector{Int})}}, AbstractVector{UnitRange{Int}}, AbstractVector{Range{Int}}, AbstractVector{A}) +typealias RangeVecIntList{A<:AbstractVector{Int}} Union{Tuple{Vararg{Union{Range, AbstractVector{Int}}}}, AbstractVector{UnitRange{Int}}, AbstractVector{Range{Int}}, AbstractVector{A}} get(A::AbstractArray, i::Integer, default) = in_bounds(length(A), i) ? A[i] : default get(A::AbstractArray, I::Tuple{}, default) = similar(A, typeof(default), 0) get(A::AbstractArray, I::Dims, default) = in_bounds(size(A), I...) ? A[I...] : default -function get!{T}(X::AbstractArray{T}, A::AbstractArray, I::Union(Range, AbstractVector{Int}), default::T) +function get!{T}(X::AbstractArray{T}, A::AbstractArray, I::Union{Range, AbstractVector{Int}}, default::T) ind = findin(I, 1:length(A)) X[ind] = A[I[ind]] X[1:first(ind)-1] = default diff --git a/base/array.jl b/base/array.jl index e8b94ce096567..b850f5949061c 100644 --- a/base/array.jl +++ b/base/array.jl @@ -4,11 +4,11 @@ typealias Vector{T} Array{T,1} typealias Matrix{T} Array{T,2} -typealias VecOrMat{T} Union(Vector{T}, Matrix{T}) +typealias VecOrMat{T} Union{Vector{T}, Matrix{T}} typealias DenseVector{T} DenseArray{T,1} typealias DenseMatrix{T} DenseArray{T,2} -typealias DenseVecOrMat{T} Union(DenseVector{T}, DenseMatrix{T}) +typealias DenseVecOrMat{T} Union{DenseVector{T}, DenseMatrix{T}} call{T}(::Type{Vector{T}}, m::Integer) = Array{T}(m) call{T}(::Type{Vector{T}}) = Array{T}(0) @@ -42,8 +42,8 @@ function call{P<:Ptr,T}(::Type{Ref{P}}, a::Array{T}) # Ref{P<:Ptr}(a::Array) return RefArray(ptrs,1,roots) end end -cconvert{P<:Ptr,T<:Ptr}(::Union(Type{Ptr{P}},Type{Ref{P}}), a::Array{T}) = a -cconvert{P<:Ptr}(::Union(Type{Ptr{P}},Type{Ref{P}}), a::Array) = Ref{P}(a) +cconvert{P<:Ptr,T<:Ptr}(::Union{Type{Ptr{P}},Type{Ref{P}}}, a::Array{T}) = a +cconvert{P<:Ptr}(::Union{Type{Ptr{P}},Type{Ref{P}}}, a::Array) = Ref{P}(a) size(a::Array, d) = arraysize(a, d) size(a::Vector) = (arraysize(a,1),) @@ -179,12 +179,12 @@ end if _oldstyle_array_vcat_ # T[a:b] and T[a:s:b] also construct typed ranges -function getindex{T<:Union(Char,Number)}(::Type{T}, r::Range) +function getindex{T<:Union{Char,Number}}(::Type{T}, r::Range) depwarn("T[a:b] concatenation is deprecated; use T[a:b;] instead", :getindex) copy!(Array(T,length(r)), r) end -function getindex{T<:Union(Char,Number)}(::Type{T}, r1::Range, rs::Range...) +function getindex{T<:Union{Char,Number}}(::Type{T}, r1::Range, rs::Range...) depwarn("T[a:b,...] concatenation is deprecated; use T[a:b;...] instead", :getindex) a = Array(T,length(r1)+sum(length,rs)) o = 1 @@ -198,12 +198,12 @@ function getindex{T<:Union(Char,Number)}(::Type{T}, r1::Range, rs::Range...) end end #_oldstyle_array_vcat_ -function fill!(a::Union(Array{UInt8}, Array{Int8}), x::Integer) +function fill!(a::Union{Array{UInt8}, Array{Int8}}, x::Integer) ccall(:memset, Ptr{Void}, (Ptr{Void}, Cint, Csize_t), a, x, length(a)) return a end -function fill!{T<:Union(Integer,FloatingPoint)}(a::Array{T}, x) +function fill!{T<:Union{Integer,FloatingPoint}}(a::Array{T}, x) # note: checking bit pattern xT = convert(T,x) if isbits(T) && nfields(T)==0 && diff --git a/base/bitarray.jl b/base/bitarray.jl index 58d0d80f6eefb..3b1d10943dbc9 100644 --- a/base/bitarray.jl +++ b/base/bitarray.jl @@ -717,7 +717,7 @@ end const _default_bit_splice = BitVector(0) -function splice!(B::BitVector, r::Union(UnitRange{Int}, Integer), ins::AbstractArray = _default_bit_splice) +function splice!(B::BitVector, r::Union{UnitRange{Int}, Integer}, ins::AbstractArray = _default_bit_splice) n = length(B) i_f = first(r) i_l = last(r) @@ -758,7 +758,7 @@ function splice!(B::BitVector, r::Union(UnitRange{Int}, Integer), ins::AbstractA return v end -function splice!(B::BitVector, r::Union(UnitRange{Int}, Integer), ins) +function splice!(B::BitVector, r::Union{UnitRange{Int}, Integer}, ins) Bins = BitArray(length(ins)) i = 1 for x in ins @@ -1618,7 +1618,7 @@ ctranspose(B::BitArray) = transpose(B) ## Permute array dims ## -function permutedims(B::Union(BitArray,StridedArray), perm) +function permutedims(B::Union{BitArray,StridedArray}, perm) dimsB = size(B) ndimsB = length(dimsB) (ndimsB == length(perm) && isperm(perm)) || throw(ArgumentError("no valid permutation of dimensions")) @@ -1658,7 +1658,7 @@ function vcat(V::BitVector...) return B end -function hcat(A::Union(BitMatrix,BitVector)...) +function hcat(A::Union{BitMatrix,BitVector}...) nargs = length(A) nrows = size(A[1], 1) ncols = 0 @@ -1708,7 +1708,7 @@ function vcat(A::BitMatrix...) end # general case, specialized for BitArrays and Integers -function cat(catdim::Integer, X::Union(BitArray, Integer)...) +function cat(catdim::Integer, X::Union{BitArray, Integer}...) nargs = length(X) # using integers results in conversion to Array{Int} # (except in the all-Bool case) diff --git a/base/broadcast.jl b/base/broadcast.jl index 5c6e3bec4bb45..00a357973d782 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -22,13 +22,13 @@ longer_tuple(x::Tuple, retx::Tuple, y::Tuple, rety::Tuple) = longer_tuple(droparg1(x...), retx, droparg1(y...), rety) longer_tuple(x::Tuple, y::Tuple) = longer_tuple(x, x, y, y) -longer_size(x::Union(AbstractArray,Number)) = size(x) -longer_size(x::Union(AbstractArray,Number), y::Union(AbstractArray,Number)...) = +longer_size(x::Union{AbstractArray,Number}) = size(x) +longer_size(x::Union{AbstractArray,Number}, y::Union{AbstractArray,Number}...) = longer_tuple(size(x), longer_size(y...)) # Calculate the broadcast shape of the arguments, or error if incompatible broadcast_shape() = () -function broadcast_shape(As::Union(AbstractArray,Number)...) +function broadcast_shape(As::Union{AbstractArray,Number}...) sz = longer_size(As...) nd = length(sz) bshape = ones(Int, nd) @@ -48,7 +48,7 @@ function broadcast_shape(As::Union(AbstractArray,Number)...) end # Check that all arguments are broadcast compatible with shape -function check_broadcast_shape(shape::Dims, As::Union(AbstractArray,Number)...) +function check_broadcast_shape(shape::Dims, As::Union{AbstractArray,Number}...) for A in As if ndims(A) > length(shape) throw(DimensionMismatch("cannot broadcast array to have fewer dimensions")) @@ -207,9 +207,9 @@ function gen_broadcast_function_tobitarray(genbody::Function, nd::Int, narrays:: end for (Bsig, Asig, gbf, gbb) in - ((BitArray , Union(Array,BitArray,Number) , + ((BitArray , Union{Array,BitArray,Number} , :gen_broadcast_function_tobitarray, :gen_broadcast_body_iter_tobitarray ), - (Any , Union(Array,BitArray,Number) , + (Any , Union{Array,BitArray,Number} , :gen_broadcast_function , :gen_broadcast_body_iter ), (BitArray , Any , :gen_broadcast_function_tobitarray, :gen_broadcast_body_cartesian_tobitarray), @@ -318,8 +318,8 @@ function .\(A::AbstractArray, B::AbstractArray) broadcast!(\, Array(type_div(eltype(A), eltype(B)), broadcast_shape(A, B)), A, B) end -typealias RatIntT{T<:Integer} Union(Type{Rational{T}},Type{T}) -typealias CRatIntT{T<:Integer} Union(Type{Complex{Rational{T}}},Type{Complex{T}},Type{Rational{T}},Type{T}) +typealias RatIntT{T<:Integer} Union{Type{Rational{T}},Type{T}} +typealias CRatIntT{T<:Integer} Union{Type{Complex{Rational{T}}},Type{Complex{T}},Type{Rational{T}},Type{T}} type_rdiv{T<:Integer,S<:Integer}(::RatIntT{T}, ::RatIntT{S}) = Rational{promote_type(T,S)} type_rdiv{T<:Integer,S<:Integer}(::CRatIntT{T}, ::CRatIntT{S}) = diff --git a/base/c.jl b/base/c.jl index 20508c844bd3c..6761dcadd14c7 100644 --- a/base/c.jl +++ b/base/c.jl @@ -58,7 +58,7 @@ else bitstype 32 Cwstring end -convert{T<:Union(Int8,UInt8)}(::Type{Cstring}, p::Ptr{T}) = box(Cstring, unbox(Ptr{T}, p)) +convert{T<:Union{Int8,UInt8}}(::Type{Cstring}, p::Ptr{T}) = box(Cstring, unbox(Ptr{T}, p)) convert(::Type{Cwstring}, p::Ptr{Cwchar_t}) = box(Cwstring, unbox(Ptr{Cwchar_t}, p)) # convert strings to ByteString etc. to pass as pointers @@ -91,11 +91,11 @@ sigatomic_end() = ccall(:jl_sigatomic_end, Void, ()) disable_sigint(f::Function) = try sigatomic_begin(); f(); finally sigatomic_end(); end reenable_sigint(f::Function) = try sigatomic_end(); f(); finally sigatomic_begin(); end -function ccallable(f::Function, rt::Type, argt::Type, name::Union(AbstractString,Symbol)=string(f)) +function ccallable(f::Function, rt::Type, argt::Type, name::Union{AbstractString,Symbol}=string(f)) ccall(:jl_extern_c, Void, (Any, Any, Any, Cstring), f, rt, argt, name) end -function ccallable(f::Function, argt::Type, name::Union(AbstractString,Symbol)=string(f)) +function ccallable(f::Function, argt::Type, name::Union{AbstractString,Symbol}=string(f)) ccall(:jl_extern_c, Void, (Any, Ptr{Void}, Any, Cstring), f, C_NULL, argt, name) end diff --git a/base/client.jl b/base/client.jl index 3cf3378da5ccf..7c32ca7abcd8c 100644 --- a/base/client.jl +++ b/base/client.jl @@ -408,7 +408,7 @@ function _start() global active_repl_backend if repl if !isa(STDIN,TTY) - global is_interactive |= !isa(STDIN,Union(File,IOStream)) + global is_interactive |= !isa(STDIN,Union{File,IOStream}) color_set || (global have_color = false) else term = Terminals.TTYTerminal(get(ENV,"TERM",@windows? "" : "dumb"),STDIN,STDOUT,STDERR) diff --git a/base/combinatorics.jl b/base/combinatorics.jl index 1cad7c27e596a..2ea978a7eacab 100644 --- a/base/combinatorics.jl +++ b/base/combinatorics.jl @@ -34,16 +34,16 @@ end factorial(n::Int128) = factorial_lookup(n, _fact_table128, 33) factorial(n::UInt128) = factorial_lookup(n, _fact_table128, 34) -factorial(n::Union(Int64,UInt64)) = factorial_lookup(n, _fact_table64, 20) +factorial(n::Union{Int64,UInt64}) = factorial_lookup(n, _fact_table64, 20) if Int === Int32 -factorial(n::Union(Int8,UInt8,Int16,UInt16)) = factorial(Int32(n)) -factorial(n::Union(Int32,UInt32)) = factorial_lookup(n, _fact_table64, 12) +factorial(n::Union{Int8,UInt8,Int16,UInt16}) = factorial(Int32(n)) +factorial(n::Union{Int32,UInt32}) = factorial_lookup(n, _fact_table64, 12) else -factorial(n::Union(Int8,UInt8,Int16,UInt16,Int32,UInt32)) = factorial(Int64(n)) +factorial(n::Union{Int8,UInt8,Int16,UInt16,Int32,UInt32}) = factorial(Int64(n)) end -function gamma(n::Union(Int8,UInt8,Int16,UInt16,Int32,UInt32,Int64,UInt64)) +function gamma(n::Union{Int8,UInt8,Int16,UInt16,Int32,UInt32,Int64,UInt64}) n < 0 && throw(DomainError()) n == 0 && return Inf n <= 2 && return 1.0 diff --git a/base/complex.jl b/base/complex.jl index f149e4f3c22bc..e31d4e87c9930 100644 --- a/base/complex.jl +++ b/base/complex.jl @@ -149,10 +149,10 @@ function /{T<:Real}(a::Complex{T}, b::Complex{T}) end end -inv{T<:Union(Float16,Float32)}(z::Complex{T}) = +inv{T<:Union{Float16,Float32}}(z::Complex{T}) = oftype(z, conj(widen(z))/abs2(widen(z))) -/{T<:Union(Float16,Float32)}(z::Complex{T}, w::Complex{T}) = +/{T<:Union{Float16,Float32}}(z::Complex{T}, w::Complex{T}) = oftype(z, widen(z)*inv(widen(w))) # robust complex division for double precision @@ -732,7 +732,7 @@ big{T<:Integer}(z::Complex{T}) = Complex{BigInt}(z) complex{T<:Complex}(x::AbstractArray{T}) = x -complex{T<:Union(Integer64,Float64,Float32,Float16)}(x::AbstractArray{T}) = +complex{T<:Union{Integer64,Float64,Float32,Float16}}(x::AbstractArray{T}) = convert(AbstractArray{typeof(complex(zero(T)))}, x) function complex(A::AbstractArray) @@ -745,7 +745,7 @@ big{T<:FloatingPoint,N}(x::AbstractArray{Complex{T},N}) = convert(AbstractArray{ ## promotion to complex ## -promote_array_type{S<:Union(Complex, Real), AT<:FloatingPoint}(::Type{S}, ::Type{Complex{AT}}) = Complex{AT} +promote_array_type{S<:Union{Complex, Real}, AT<:FloatingPoint}(::Type{S}, ::Type{Complex{AT}}) = Complex{AT} function complex{S<:Real,T<:Real}(A::Array{S}, B::Array{T}) if size(A) != size(B); throw(DimensionMismatch()); end diff --git a/base/constants.jl b/base/constants.jl index dda7b8e39cfee..3a97fc779e883 100644 --- a/base/constants.jl +++ b/base/constants.jl @@ -15,7 +15,7 @@ convert(::Type{Float16}, x::MathConst) = Float16(Float32(x)) convert{T<:Real}(::Type{Complex{T}}, x::MathConst) = convert(Complex{T}, convert(T,x)) convert{T<:Integer}(::Type{Rational{T}}, x::MathConst) = convert(Rational{T}, Float64(x)) -@generated function call{T<:Union(Float32,Float64),s}(t::Type{T},c::MathConst{s},r::RoundingMode) +@generated function call{T<:Union{Float32,Float64},s}(t::Type{T},c::MathConst{s},r::RoundingMode) f = T(big(c()),r()) :($f) end diff --git a/base/coreimg.jl b/base/coreimg.jl index d70ea95008e12..2fec5c8511897 100644 --- a/base/coreimg.jl +++ b/base/coreimg.jl @@ -43,7 +43,7 @@ include("abstractarray.jl") typealias StridedArray{T,N,A<:DenseArray,I<:Tuple{Vararg{RangeIndex}}} DenseArray{T,N} typealias StridedVector{T,A<:DenseArray,I<:Tuple{Vararg{RangeIndex}}} DenseArray{T,1} typealias StridedMatrix{T,A<:DenseArray,I<:Tuple{Vararg{RangeIndex}}} DenseArray{T,2} -typealias StridedVecOrMat{T} Union(StridedVector{T}, StridedMatrix{T}) +typealias StridedVecOrMat{T} Union{StridedVector{T}, StridedMatrix{T}} include("array.jl") #TODO: eliminate Dict from inference diff --git a/base/datafmt.jl b/base/datafmt.jl index 30cba3ab4079a..0b123ec705808 100644 --- a/base/datafmt.jl +++ b/base/datafmt.jl @@ -289,7 +289,7 @@ const valid_opts = [:header, :has_header, :ignore_invalid_chars, :use_mmap, :quo const valid_opt_types = [Bool, Bool, Bool, Bool, Bool, Bool, NTuple{2,Integer}, Char, Integer, Bool] const deprecated_opts = Dict(:has_header => :header) function val_opts(opts) - d = Dict{Symbol,Union(Bool,NTuple{2,Integer},Char,Integer)}() + d = Dict{Symbol,Union{Bool,NTuple{2,Integer},Char,Integer}}() for (opt_name, opt_val) in opts !in(opt_name, valid_opts) && throw(ArgumentError("unknown option $opt_name")) opt_typ = valid_opt_types[findfirst(valid_opts, opt_name)] diff --git a/base/dates/adjusters.jl b/base/dates/adjusters.jl index b297632a26435..4ce1873b5f048 100644 --- a/base/dates/adjusters.jl +++ b/base/dates/adjusters.jl @@ -130,13 +130,13 @@ function toprev(func::Function,dt::TimeType;step::Period=Day(-1),negate::Bool=fa end # Return the first TimeType that falls on dow in the Month or Year -function tofirst(dt::TimeType,dow::Int;of::Union(Type{Year},Type{Month})=Month) +function tofirst(dt::TimeType,dow::Int;of::Union{Type{Year},Type{Month}}=Month) dt = of <: Month ? firstdayofmonth(dt) : firstdayofyear(dt) return adjust(ISDAYOFWEEK[dow],dt,Day(1),366) end # Return the last TimeType that falls on dow in the Month or Year -function tolast(dt::TimeType,dow::Int;of::Union(Type{Year},Type{Month})=Month) +function tolast(dt::TimeType,dow::Int;of::Union{Type{Year},Type{Month}}=Month) dt = of <: Month ? lastdayofmonth(dt) : lastdayofyear(dt) return adjust(ISDAYOFWEEK[dow],dt,Day(-1),366) end diff --git a/base/dates/periods.jl b/base/dates/periods.jl index ee30e8b26eacf..0e3b9112dac00 100644 --- a/base/dates/periods.jl +++ b/base/dates/periods.jl @@ -24,14 +24,14 @@ Base.convert{T<:Period}(::Type{T},x::Real) = T(x) #Print/show/traits Base.string{P<:Period}(x::P) = string(value(x),_units(x)) Base.show(io::IO,x::Period) = print(io,string(x)) -Base.zero{P<:Period}(::Union(Type{P},P)) = P(0) -Base.one{P<:Period}(::Union(Type{P},P)) = P(1) +Base.zero{P<:Period}(::Union{Type{P},P}) = P(0) +Base.one{P<:Period}(::Union{Type{P},P}) = P(1) Base.typemin{P<:Period}(::Type{P}) = P(typemin(Int64)) Base.typemax{P<:Period}(::Type{P}) = P(typemax(Int64)) # Default values (as used by TimeTypes) -default{T<:DatePeriod}(p::Union(T,Type{T})) = one(p) -default{T<:TimePeriod}(p::Union(T,Type{T})) = zero(p) +default{T<:DatePeriod}(p::Union{T,Type{T}}) = one(p) +default{T<:TimePeriod}(p::Union{T,Type{T}}) = zero(p) (-){P<:Period}(x::P) = P(-value(x)) Base.isless{P<:Period}(x::P,y::P) = isless(value(x),value(y)) @@ -201,7 +201,7 @@ Base.show(io::IO,x::CompoundPeriod) = print(io,string(x)) (-)(x::Period,y::Period) = CompoundPeriod(Period[x,-y]) (-)(x::CompoundPeriod,y::Period) = CompoundPeriod(vcat(x.periods,-y)) (-)(x::CompoundPeriod) = CompoundPeriod(-x.periods) -(-)(y::Union(Period,CompoundPeriod),x::CompoundPeriod) = (-x) + y +(-)(y::Union{Period,CompoundPeriod},x::CompoundPeriod) = (-x) + y (==)(x::CompoundPeriod, y::Period) = x == CompoundPeriod(y) (==)(y::Period, x::CompoundPeriod) = x == y (==)(x::CompoundPeriod, y::CompoundPeriod) = x.periods == y.periods @@ -222,7 +222,7 @@ end # Fixed-value Periods (periods corresponding to a well-defined time interval, # as opposed to variable calendar intervals like Year). -typealias FixedPeriod Union(Week,Day,Hour,Minute,Second,Millisecond) +typealias FixedPeriod Union{Week,Day,Hour,Minute,Second,Millisecond} # like div but throw an error if remainder is nonzero function divexact(x,y) @@ -259,7 +259,7 @@ end Base.isless{T<:FixedPeriod,S<:FixedPeriod}(x::T,y::S) = isless(promote(x,y)...) # other periods with fixed conversions but which aren't fixed time periods -typealias OtherPeriod Union(Month,Year) +typealias OtherPeriod Union{Month,Year} let vmax = typemax(Int64) ÷ 12, vmin = typemin(Int64) ÷ 12 @eval function Base.convert(::Type{Month}, x::Year) $vmin ≤ value(x) ≤ $vmax || throw(InexactError()) diff --git a/base/dates/types.jl b/base/dates/types.jl index c3b0376c52ed3..ce9c7cb933ee1 100644 --- a/base/dates/types.jl +++ b/base/dates/types.jl @@ -135,15 +135,15 @@ DateTime(y,m=1,d=1,h=0,mi=0,s=0,ms=0) = DateTime(_c(y),_c(m),_c(d),_c(h),_c(mi), Date(y,m=1,d=1) = Date(_c(y),_c(m),_c(d)) # Traits, Equality -Base.isfinite{T<:TimeType}(::Union(Type{T},T)) = true +Base.isfinite{T<:TimeType}(::Union{Type{T},T}) = true calendar(dt::DateTime) = ISOCalendar calendar(dt::Date) = ISOCalendar Base.eps(dt::DateTime) = Millisecond(1) Base.eps(dt::Date) = Day(1) -Base.typemax(::Union(DateTime,Type{DateTime})) = DateTime(146138512,12,31,23,59,59) -Base.typemin(::Union(DateTime,Type{DateTime})) = DateTime(-146138511,1,1,0,0,0) -Base.typemax(::Union(Date,Type{Date})) = Date(252522163911149,12,31) -Base.typemin(::Union(Date,Type{Date})) = Date(-252522163911150,1,1) +Base.typemax(::Union{DateTime,Type{DateTime}}) = DateTime(146138512,12,31,23,59,59) +Base.typemin(::Union{DateTime,Type{DateTime}}) = DateTime(-146138511,1,1,0,0,0) +Base.typemax(::Union{Date,Type{Date}}) = Date(252522163911149,12,31) +Base.typemin(::Union{Date,Type{Date}}) = Date(-252522163911150,1,1) # Date-DateTime promotion, isless, == Base.promote_rule(::Type{Date},x::Type{DateTime}) = DateTime Base.isless(x::Date,y::Date) = isless(value(x),value(y)) diff --git a/base/deepcopy.jl b/base/deepcopy.jl index 96b1a1ccf2ce4..3b5ba7f7cc1f9 100644 --- a/base/deepcopy.jl +++ b/base/deepcopy.jl @@ -7,15 +7,15 @@ deepcopy(x) = deepcopy_internal(x, ObjectIdDict()) -deepcopy_internal(x::Union(Symbol,LambdaStaticData,TopNode,QuoteNode, - DataType,Union,Task), +deepcopy_internal(x::Union{Symbol,LambdaStaticData,TopNode,QuoteNode, + DataType,Union,Task}, stackdict::ObjectIdDict) = x deepcopy_internal(x::Tuple, stackdict::ObjectIdDict) = ntuple(i->deepcopy_internal(x[i], stackdict), length(x)) deepcopy_internal(x::Module, stackdict::ObjectIdDict) = error("deepcopy of Modules not supported") function deepcopy_internal(x::Function, stackdict::ObjectIdDict) - if isa(x.env, Union(MethodTable, Symbol)) || x.env === () + if isa(x.env, Union{MethodTable, Symbol}) || x.env === () return x end invoke(deepcopy_internal, Tuple{Any, ObjectIdDict}, x, stackdict) diff --git a/base/deprecated.jl b/base/deprecated.jl index b3dd9b98049a2..ada1adfca536d 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -108,7 +108,7 @@ export Nothing const Nothing = Void export None -const None = Union() +const None = Union{} export apply function apply(f, args...) @@ -428,7 +428,7 @@ function to_index{T<:Real}(A::AbstractArray{T}) Int[to_index_nodep(x) for x in A] end -function float_isvalid{T<:Union(Float32,Float64)}(s::AbstractString, out::Array{T,1}) +function float_isvalid{T<:Union{Float32,Float64}}(s::AbstractString, out::Array{T,1}) tf = tryparse(T, s) isnull(tf) || (out[1] = get(tf)) !isnull(tf) @@ -486,7 +486,7 @@ export float32_isvalid, float64_isvalid function chol(A::AbstractMatrix, uplo::Symbol) depwarn(string("chol(a::AbstractMatrix, uplo::Symbol) is deprecated, ", - "use chol(a::AbstractMatrix, uplo::Union(Val{:L},Val{:U})) instead"), :chol) + "use chol(a::AbstractMatrix, uplo::Union{Val{:L},Val{:U}}) instead"), :chol) chol(A, Val{uplo}) end @@ -494,7 +494,7 @@ _ensure_vector(A::AbstractArray) = vec(A) _ensure_vector(A) = A _ensure_vectors() = () _ensure_vectors(A, As...) = (_ensure_vector(A), _ensure_vectors(As...)...) -function _unsafe_setindex!(l::LinearIndexing, A::AbstractArray, x, J::Union(Real,AbstractArray,Colon)...) +function _unsafe_setindex!(l::LinearIndexing, A::AbstractArray, x, J::Union{Real,AbstractArray,Colon}...) depwarn("multidimensional indexed assignment with multidimensional arrays is deprecated, use vec to convert indices to vectors", :_unsafe_setindex!) _unsafe_setindex!(l, A, x, _ensure_vectors(J...)...) end diff --git a/base/dict.jl b/base/dict.jl index ee544bf9f30bc..5da08ef45d802 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -135,13 +135,13 @@ immutable ValueIterator{T<:Associative} dict::T end -summary{T<:Union(KeyIterator,ValueIterator)}(iter::T) = +summary{T<:Union{KeyIterator,ValueIterator}}(iter::T) = string(T.name, " for a ", summary(iter.dict)) -show(io::IO, iter::Union(KeyIterator,ValueIterator)) = show(io, collect(iter)) +show(io::IO, iter::Union{KeyIterator,ValueIterator}) = show(io, collect(iter)) -showkv(iter::Union(KeyIterator,ValueIterator); kw...) = showkv(STDOUT, iter; kw...) -function showkv{T<:Union(KeyIterator,ValueIterator)}(io::IO, iter::T; limit::Bool = false, +showkv(iter::Union{KeyIterator,ValueIterator}; kw...) = showkv(STDOUT, iter; kw...) +function showkv{T<:Union{KeyIterator,ValueIterator}}(io::IO, iter::T; limit::Bool = false, sz=(s = tty_size(); (s[1]-3, s[2]))) rows, cols = sz print(io, summary(iter)) @@ -168,15 +168,15 @@ function showkv{T<:Union(KeyIterator,ValueIterator)}(io::IO, iter::T; limit::Boo end end -length(v::Union(KeyIterator,ValueIterator)) = length(v.dict) -isempty(v::Union(KeyIterator,ValueIterator)) = isempty(v.dict) +length(v::Union{KeyIterator,ValueIterator}) = length(v.dict) +isempty(v::Union{KeyIterator,ValueIterator}) = isempty(v.dict) _tt1{A,B}(::Type{Tuple{A,B}}) = A _tt2{A,B}(::Type{Tuple{A,B}}) = B eltype{D}(::Type{KeyIterator{D}}) = _tt1(eltype(D)) eltype{D}(::Type{ValueIterator{D}}) = _tt2(eltype(D)) -start(v::Union(KeyIterator,ValueIterator)) = start(v.dict) -done(v::Union(KeyIterator,ValueIterator), state) = done(v.dict, state) +start(v::Union{KeyIterator,ValueIterator}) = start(v.dict) +done(v::Union{KeyIterator,ValueIterator}, state) = done(v.dict, state) function next(v::KeyIterator, state) n = next(v.dict, state) diff --git a/base/dsp.jl b/base/dsp.jl index 4cffce39a5a79..0f6e32013a30a 100644 --- a/base/dsp.jl +++ b/base/dsp.jl @@ -15,14 +15,14 @@ export FFTW, filt, filt!, deconv, conv, conv2, xcorr, fftshift, ifftshift, _zerosi(b,a,T) = zeros(promote_type(eltype(b), eltype(a), T), max(length(a), length(b))-1) -function filt{T,S}(b::Union(AbstractVector, Number), a::Union(AbstractVector, Number), +function filt{T,S}(b::Union{AbstractVector, Number}, a::Union{AbstractVector, Number}, x::AbstractArray{T}, si::AbstractArray{S}=_zerosi(b,a,T)) filt!(Array(promote_type(eltype(b), eltype(a), T, S), size(x)), b, a, x, si) end # in-place filtering: returns results in the out argument, which may shadow x # (and does so by default) -function filt!{T,S,N}(out::AbstractArray, b::Union(AbstractVector, Number), a::Union(AbstractVector, Number), +function filt!{T,S,N}(out::AbstractArray, b::Union{AbstractVector, Number}, a::Union{AbstractVector, Number}, x::AbstractArray{T}, si::AbstractArray{S,N}=_zerosi(b,a,T)) isempty(b) && throw(ArgumentError("filter vector b must be non-empty")) isempty(a) && throw(ArgumentError("filter vector a must be non-empty")) diff --git a/base/expr.jl b/base/expr.jl index 54cc5510d03c8..9a322edc9c573 100644 --- a/base/expr.jl +++ b/base/expr.jl @@ -15,7 +15,7 @@ gensym(s::ASCIIString) = gensym(s.data) gensym(s::UTF8String) = gensym(s.data) gensym(a::Array{UInt8,1}) = ccall(:jl_tagged_gensym, Any, (Ptr{UInt8}, Int32), a, length(a))::Symbol -gensym(ss::Union(ASCIIString, UTF8String)...) = map(gensym, ss) +gensym(ss::Union{ASCIIString, UTF8String}...) = map(gensym, ss) gensym(s::Symbol) = ccall(:jl_tagged_gensym, Any, (Ptr{UInt8}, Int32), s, ccall(:strlen, Csize_t, (Ptr{UInt8},), s))::Symbol @@ -38,7 +38,7 @@ copy(e::Expr) = (n = Expr(e.head); copy(s::SymbolNode) = SymbolNode(s.name, s.typ) # copy parts of an AST that the compiler mutates -astcopy(x::Union(SymbolNode,Expr)) = copy(x) +astcopy(x::Union{SymbolNode,Expr}) = copy(x) astcopy(x::Array{Any,1}) = Any[astcopy(a) for a in x] astcopy(x) = x diff --git a/base/fastmath.jl b/base/fastmath.jl index 8311bef6f0d11..dadb5da20d5ef 100644 --- a/base/fastmath.jl +++ b/base/fastmath.jl @@ -128,7 +128,7 @@ end # Basic arithmetic -FloatTypes = Union(Float32, Float64) +FloatTypes = Union{Float32, Float64} sub_fast{T<:FloatTypes}(x::T) = box(T,Base.neg_float_fast(unbox(T,x))) @@ -172,7 +172,7 @@ issubnormal_fast(x) = false # complex numbers -ComplexTypes = Union(Complex64, Complex128) +ComplexTypes = Union{Complex64, Complex128} @fastmath begin div_fast{T<:FloatTypes}(x::Complex{T}, y::T) = diff --git a/base/fftw.jl b/base/fftw.jl index 3f2891884af57..c5ccaa436100d 100644 --- a/base/fftw.jl +++ b/base/fftw.jl @@ -51,13 +51,13 @@ const RODFT11 = Int32(10) # FFTW floating-point types: -typealias fftwNumber Union(Float64,Float32,Complex128,Complex64) -typealias fftwReal Union(Float64,Float32) -typealias fftwComplex Union(Complex128,Complex64) -typealias fftwDouble Union(Float64,Complex128) -typealias fftwSingle Union(Float32,Complex64) -typealias fftwTypeDouble Union(Type{Float64},Type{Complex128}) -typealias fftwTypeSingle Union(Type{Float32},Type{Complex64}) +typealias fftwNumber Union{Float64,Float32,Complex128,Complex64} +typealias fftwReal Union{Float64,Float32} +typealias fftwComplex Union{Complex128,Complex64} +typealias fftwDouble Union{Float64,Complex128} +typealias fftwSingle Union{Float32,Complex64} +typealias fftwTypeDouble Union{Type{Float64},Type{Complex128}} +typealias fftwTypeSingle Union{Type{Float32},Type{Complex64}} ## Julia wrappers around FFTW functions diff --git a/base/float.jl b/base/float.jl index 215d1944910d1..f25218d733c01 100644 --- a/base/float.jl +++ b/base/float.jl @@ -289,14 +289,14 @@ for Ti in (Int64,UInt64,Int128,UInt128) end end -==(x::Float32, y::Union(Int32,UInt32)) = Float64(x)==Float64(y) -==(x::Union(Int32,UInt32), y::Float32) = Float64(x)==Float64(y) +==(x::Float32, y::Union{Int32,UInt32}) = Float64(x)==Float64(y) +==(x::Union{Int32,UInt32}, y::Float32) = Float64(x)==Float64(y) -<(x::Float32, y::Union(Int32,UInt32)) = Float64(x)>, >>>, <=, ==, >, >=, ^, (~), (&), (|), ($), bin, oct, dec, hex, isequal, invmod, prevpow2, nextpow2, ndigits0z, widen, signed if Clong == Int32 - typealias ClongMax Union(Int8, Int16, Int32) - typealias CulongMax Union(UInt8, UInt16, UInt32) + typealias ClongMax Union{Int8, Int16, Int32} + typealias CulongMax Union{UInt8, UInt16, UInt32} else - typealias ClongMax Union(Int8, Int16, Int32, Int64) - typealias CulongMax Union(UInt8, UInt16, UInt32, UInt64) + typealias ClongMax Union{Int8, Int16, Int32, Int64} + typealias CulongMax Union{UInt8, UInt16, UInt32, UInt64} end -typealias CdoubleMax Union(Float16, Float32, Float64) +typealias CdoubleMax Union{Float16, Float32, Float64} gmp_version() = VersionNumber(bytestring(unsafe_load(cglobal((:__gmp_version, :libgmp), Ptr{Cchar})))) gmp_bits_per_limb() = Int(unsafe_load(cglobal((:__gmp_bits_per_limb, :libgmp), Cint))) @@ -102,12 +102,12 @@ function tryparse_internal(::Type{BigInt}, s::AbstractString, startpos::Int, end Nullable(sgn < 0 ? -z : z) end -function BigInt(x::Union(Clong,Int32)) +function BigInt(x::Union{Clong,Int32}) z = BigInt() ccall((:__gmpz_set_si, :libgmp), Void, (Ptr{BigInt}, Clong), &z, x) return z end -function BigInt(x::Union(Culong,UInt32)) +function BigInt(x::Union{Culong,UInt32}) z = BigInt() ccall((:__gmpz_set_ui, :libgmp), Void, (Ptr{BigInt}, Culong), &z, x) return z @@ -122,7 +122,7 @@ function BigInt(x::Float64) return z end -BigInt(x::Union(Float16,Float32)) = BigInt(Float64(x)) +BigInt(x::Union{Float16,Float32}) = BigInt(Float64(x)) function BigInt(x::Integer) if x < 0 @@ -158,7 +158,7 @@ convert(::Type{BigInt}, x::FloatingPoint) = BigInt(x) rem(x::BigInt, ::Type{Bool}) = ((x&1)!=0) -function rem{T<:Union(Unsigned,Signed)}(x::BigInt, ::Type{T}) +function rem{T<:Union{Unsigned,Signed}}(x::BigInt, ::Type{T}) u = zero(T) for l = 1:min(abs(x.size), cld(sizeof(T),sizeof(Limb))) u += (unsafe_load(x.d,l)%T) << ((sizeof(Limb)<<3)*(l-1)) @@ -193,7 +193,7 @@ function call(::Type{Float64}, n::BigInt, ::RoundingMode{:ToZero}) ccall((:__gmpz_get_d, :libgmp), Float64, (Ptr{BigInt},), &n) end -function call{T<:Union(Float16,Float32)}(::Type{T}, n::BigInt, ::RoundingMode{:ToZero}) +function call{T<:Union{Float16,Float32}}(::Type{T}, n::BigInt, ::RoundingMode{:ToZero}) T(Float64(n,RoundToZero),RoundToZero) end diff --git a/base/grisu.jl b/base/grisu.jl index c8a5884451d0d..2138c7f87684d 100644 --- a/base/grisu.jl +++ b/base/grisu.jl @@ -173,6 +173,6 @@ function _print_shortest(io::IO, x::FloatingPoint, dot::Bool, mode, n::Int) end print_shortest(io::IO, x::FloatingPoint, dot::Bool) = _print_shortest(io, x, dot, SHORTEST, 0) -print_shortest(io::IO, x::Union(FloatingPoint,Integer)) = print_shortest(io, float(x), false) +print_shortest(io::IO, x::Union{FloatingPoint,Integer}) = print_shortest(io, float(x), false) end # module diff --git a/base/inference.jl b/base/inference.jl index c36f780e5a261..c9df8f216e0b4 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -316,7 +316,7 @@ const getfield_tfunc = function (A, s0, name) end return s.types[i], false else - return reduce(tmerge, Bottom, map(unwrapva,s.types)) #=Union(s.types...)=#, false + return reduce(tmerge, Bottom, map(unwrapva,s.types)) #=Union{s.types...}=#, false end end add_tfunc(getfield, 2, 2, (A,s,name)->getfield_tfunc(A,s,name)[1]) @@ -367,7 +367,7 @@ end has_typevars(t::ANY) = ccall(:jl_has_typevars, Cint, (Any,), t)!=0 -# TODO: handle e.g. apply_type(T, R::Union(Type{Int32},Type{Float64})) +# TODO: handle e.g. apply_type(T, R::Union{Type{Int32},Type{Float64}}) const apply_type_tfunc = function (A, args...) if !isType(args[1]) return Any @@ -2759,7 +2759,7 @@ function mk_tuplecall(args, sv::StaticVarInfo) e end -const corenumtype = Union(Int32,Int64,Float32,Float64) +const corenumtype = Union{Int32,Int64,Float32,Float64} function inlining_pass(e::Expr, sv, ast) if e.head == :method @@ -2864,9 +2864,9 @@ function inlining_pass(e::Expr, sv, ast) if isdefined(Main, :Base) && ((isdefined(Main.Base, :^) && is(f, Main.Base.(:^))) || (isdefined(Main.Base, :.^) && is(f, Main.Base.(:.^)))) - if length(e.args) == 3 && isa(e.args[3],Union(Int32,Int64)) + if length(e.args) == 3 && isa(e.args[3],Union{Int32,Int64}) a1 = e.args[2] - basenumtype = Union(corenumtype, Main.Base.Complex64, Main.Base.Complex128, Main.Base.Rational) + basenumtype = Union{corenumtype, Main.Base.Complex64, Main.Base.Complex128, Main.Base.Rational} if isa(a1,basenumtype) || ((isa(a1,Symbol) || isa(a1,SymbolNode) || isa(a1,GenSym)) && exprtype(a1,sv) <: basenumtype) if e.args[3]==2 diff --git a/base/int.jl b/base/int.jl index c11c7b3c5b0a7..76e6e3511063c 100644 --- a/base/int.jl +++ b/base/int.jl @@ -68,9 +68,9 @@ cld(x::Unsigned, y::Signed) = div(x,y)+(!signbit(y)&(rem(x,y)!=0)) # Don't promote integers for div/rem/mod since there no danger of overflow, # while there is a substantial performance penalty to 64-bit promotion. -typealias Signed64 Union(Int8,Int16,Int32,Int64) -typealias Unsigned64 Union(UInt8,UInt16,UInt32,UInt64) -typealias Integer64 Union(Signed64,Unsigned64) +typealias Signed64 Union{Int8,Int16,Int32,Int64} +typealias Unsigned64 Union{UInt8,UInt16,UInt32,UInt64} +typealias Integer64 Union{Signed64,Unsigned64} div{T<:Signed64} (x::T, y::T) = box(T,sdiv_int(unbox(T,x),unbox(T,y))) div{T<:Unsigned64}(x::T, y::T) = box(T,udiv_int(unbox(T,x),unbox(T,y))) @@ -246,7 +246,7 @@ convert(::Type{Unsigned}, x::Char) = convert(UInt,x) convert(::Type{Unsigned}, x::Bool) = convert(UInt,x) convert(::Type{Integer}, x::Integer) = x -convert(::Type{Integer}, x::Union(Real,Char)) = convert(Signed,x) +convert(::Type{Integer}, x::Union{Real,Char}) = convert(Signed,x) round(x::Integer) = x trunc(x::Integer) = x diff --git a/base/intfuncs.jl b/base/intfuncs.jl index 89ef71f1bd84a..8c3eae2864722 100644 --- a/base/intfuncs.jl +++ b/base/intfuncs.jl @@ -13,7 +13,7 @@ end # binary GCD (aka Stein's) algorithm # about 1.7x (2.1x) faster for random Int64s (Int128s) -function gcd{T<:Union(Int64,UInt64,Int128,UInt128)}(a::T, b::T) +function gcd{T<:Union{Int64,UInt64,Int128,UInt128}}(a::T, b::T) a == 0 && return abs(b) b == 0 && return abs(a) za = trailing_zeros(a) @@ -163,7 +163,7 @@ const powers_of_ten = [ 0x000000e8d4a51000, 0x000009184e72a000, 0x00005af3107a4000, 0x00038d7ea4c68000, 0x002386f26fc10000, 0x016345785d8a0000, 0x0de0b6b3a7640000, 0x8ac7230489e80000, ] -function ndigits0z(x::Union(UInt8,UInt16,UInt32,UInt64)) +function ndigits0z(x::Union{UInt8,UInt16,UInt32,UInt64}) lz = (sizeof(x)<<3)-leading_zeros(x) nd = (1233*lz)>>12+1 nd -= x < powers_of_ten[nd] @@ -302,11 +302,11 @@ for sym in (:bin, :oct, :dec, :hex) end end -bits(x::Union(Bool,Int8,UInt8)) = bin(reinterpret(UInt8,x),8) -bits(x::Union(Int16,UInt16,Float16)) = bin(reinterpret(UInt16,x),16) -bits(x::Union(Char,Int32,UInt32,Float32)) = bin(reinterpret(UInt32,x),32) -bits(x::Union(Int64,UInt64,Float64)) = bin(reinterpret(UInt64,x),64) -bits(x::Union(Int128,UInt128)) = bin(reinterpret(UInt128,x),128) +bits(x::Union{Bool,Int8,UInt8}) = bin(reinterpret(UInt8,x),8) +bits(x::Union{Int16,UInt16,Float16}) = bin(reinterpret(UInt16,x),16) +bits(x::Union{Char,Int32,UInt32,Float32}) = bin(reinterpret(UInt32,x),32) +bits(x::Union{Int64,UInt64,Float64}) = bin(reinterpret(UInt64,x),64) +bits(x::Union{Int128,UInt128}) = bin(reinterpret(UInt128,x),128) function digits{T<:Integer}(n::Integer, base::T=10, pad::Integer=1) 2 <= base || throw(ArgumentError("base must be ≥ 2, got $base")) @@ -327,7 +327,7 @@ end isqrt(x::Integer) = oftype(x, trunc(sqrt(x))) -function isqrt(x::Union(Int64,UInt64,Int128,UInt128)) +function isqrt(x::Union{Int64,UInt64,Int128,UInt128}) x==0 && return x s = oftype(x, trunc(sqrt(x))) # fix with a Newton iteration, since conversion to float discards diff --git a/base/libc.jl b/base/libc.jl index 6ca93e701a08f..1bfe75a82cdfd 100644 --- a/base/libc.jl +++ b/base/libc.jl @@ -46,7 +46,7 @@ function FILE(s::IO) f end -Base.unsafe_convert(T::Union(Type{Ptr{Void}},Type{Ptr{FILE}}), f::FILE) = convert(T, f.ptr) +Base.unsafe_convert(T::Union{Type{Ptr{Void}},Type{Ptr{FILE}}}, f::FILE) = convert(T, f.ptr) Base.close(f::FILE) = systemerror("fclose", ccall(:fclose, Cint, (Ptr{Void},), f.ptr) != 0) Base.convert(::Type{FILE}, s::IO) = FILE(s) diff --git a/base/libdl.jl b/base/libdl.jl index 5f46ca0432856..185f3819666aa 100644 --- a/base/libdl.jl +++ b/base/libdl.jl @@ -20,12 +20,12 @@ const RTLD_NOLOAD = 0x00000010 const RTLD_DEEPBIND = 0x00000020 const RTLD_FIRST = 0x00000040 -function dlsym(hnd::Ptr, s::Union(Symbol,AbstractString)) +function dlsym(hnd::Ptr, s::Union{Symbol,AbstractString}) hnd == C_NULL && error("NULL library handle") ccall(:jl_dlsym, Ptr{Void}, (Ptr{Void}, Cstring), hnd, s) end -function dlsym_e(hnd::Ptr, s::Union(Symbol,AbstractString)) +function dlsym_e(hnd::Ptr, s::Union{Symbol,AbstractString}) hnd == C_NULL && error("NULL library handle") ccall(:jl_dlsym_e, Ptr{Void}, (Ptr{Void}, Cstring), hnd, s) end @@ -68,7 +68,7 @@ function dlpath( handle::Ptr{Void} ) return s end -function dlpath(libname::Union(AbstractString, Symbol)) +function dlpath(libname::Union{AbstractString, Symbol}) handle = dlopen(libname) path = dlpath(handle) dlclose(handle) diff --git a/base/linalg.jl b/base/linalg.jl index 18b8cc41c61ba..8659acc51bdbb 100644 --- a/base/linalg.jl +++ b/base/linalg.jl @@ -152,9 +152,9 @@ export # Constants I -typealias BlasFloat Union(Float64,Float32,Complex128,Complex64) -typealias BlasReal Union(Float64,Float32) -typealias BlasComplex Union(Complex128,Complex64) +typealias BlasFloat Union{Float64,Float32,Complex128,Complex64} +typealias BlasReal Union{Float64,Float32} +typealias BlasComplex Union{Complex128,Complex64} if USE_BLAS64 typealias BlasInt Int64 diff --git a/base/linalg/bidiag.jl b/base/linalg/bidiag.jl index 6c29d7e65b6f9..0209b094db380 100644 --- a/base/linalg/bidiag.jl +++ b/base/linalg/bidiag.jl @@ -133,7 +133,7 @@ end /(A::Bidiagonal, B::Number) = Bidiagonal(A.dv/B, A.ev/B, A.isupper) ==(A::Bidiagonal, B::Bidiagonal) = (A.dv==B.dv) && (A.ev==B.ev) && (A.isupper==B.isupper) -SpecialMatrix = Union(Diagonal, Bidiagonal, SymTridiagonal, Tridiagonal, AbstractTriangular) +SpecialMatrix = Union{Diagonal, Bidiagonal, SymTridiagonal, Tridiagonal, AbstractTriangular} *(A::SpecialMatrix, B::SpecialMatrix)=full(A)*full(B) #Generic multiplication @@ -142,10 +142,10 @@ for func in (:*, :Ac_mul_B, :A_mul_Bc, :/, :A_rdiv_Bc) end #Linear solvers -A_ldiv_B!(A::Union(Bidiagonal, AbstractTriangular), b::AbstractVector) = naivesub!(A, b) -At_ldiv_B!(A::Union(Bidiagonal, AbstractTriangular), b::AbstractVector) = naivesub!(transpose(A), b) -Ac_ldiv_B!(A::Union(Bidiagonal, AbstractTriangular), b::AbstractVector) = naivesub!(ctranspose(A), b) -function A_ldiv_B!(A::Union(Bidiagonal, AbstractTriangular), B::AbstractMatrix) +A_ldiv_B!(A::Union{Bidiagonal, AbstractTriangular}, b::AbstractVector) = naivesub!(A, b) +At_ldiv_B!(A::Union{Bidiagonal, AbstractTriangular}, b::AbstractVector) = naivesub!(transpose(A), b) +Ac_ldiv_B!(A::Union{Bidiagonal, AbstractTriangular}, b::AbstractVector) = naivesub!(ctranspose(A), b) +function A_ldiv_B!(A::Union{Bidiagonal, AbstractTriangular}, B::AbstractMatrix) nA,mA = size(A) tmp = similar(B,size(B,1)) n = size(B, 1) @@ -159,10 +159,10 @@ function A_ldiv_B!(A::Union(Bidiagonal, AbstractTriangular), B::AbstractMatrix) end B end -A_ldiv_B(A::Union(Bidiagonal, AbstractTriangular), B::AbstractMatrix) = A_ldiv_B!(A,copy(B)) +A_ldiv_B(A::Union{Bidiagonal, AbstractTriangular}, B::AbstractMatrix) = A_ldiv_B!(A,copy(B)) for func in (:Ac_ldiv_B!, :At_ldiv_B!) - @eval function ($func)(A::Union(Bidiagonal, AbstractTriangular), B::AbstractMatrix) + @eval function ($func)(A::Union{Bidiagonal, AbstractTriangular}, B::AbstractMatrix) nA,mA = size(A) tmp = similar(B,size(B,1)) n = size(B, 1) @@ -177,8 +177,8 @@ for func in (:Ac_ldiv_B!, :At_ldiv_B!) B end end -Ac_ldiv_B(A::Union(Bidiagonal, AbstractTriangular), B::AbstractMatrix) = Ac_ldiv_B!(A,copy(B)) -At_ldiv_B(A::Union(Bidiagonal, AbstractTriangular), B::AbstractMatrix) = At_ldiv_B!(A,copy(B)) +Ac_ldiv_B(A::Union{Bidiagonal, AbstractTriangular}, B::AbstractMatrix) = Ac_ldiv_B!(A,copy(B)) +At_ldiv_B(A::Union{Bidiagonal, AbstractTriangular}, B::AbstractMatrix) = At_ldiv_B!(A,copy(B)) #Generic solver using naive substitution function naivesub!{T}(A::Bidiagonal{T}, b::AbstractVector, x::AbstractVector = b) diff --git a/base/linalg/bitarray.jl b/base/linalg/bitarray.jl index 9eeedb1136fd9..eee50e259145b 100644 --- a/base/linalg/bitarray.jl +++ b/base/linalg/bitarray.jl @@ -86,7 +86,7 @@ function diag(B::BitMatrix) v end -function diagm(v::Union(BitVector,BitMatrix)) +function diagm(v::Union{BitVector,BitMatrix}) isa(v, BitMatrix) && size(v,1)==1 || size(v,2)==1 || throw(DimensionMismatch()) n = length(v) a = falses(n, n) diff --git a/base/linalg/blas.jl b/base/linalg/blas.jl index a69ae49c323bc..6dc42738c00d5 100644 --- a/base/linalg/blas.jl +++ b/base/linalg/blas.jl @@ -68,7 +68,7 @@ for (fname, elty) in ((:dcopy_,:Float64), (:ccopy_,:Complex64)) @eval begin # SUBROUTINE DCOPY(N,DX,INCX,DY,INCY) - function blascopy!(n::Integer, DX::Union(Ptr{$elty},StridedArray{$elty}), incx::Integer, DY::Union(Ptr{$elty},StridedArray{$elty}), incy::Integer) + function blascopy!(n::Integer, DX::Union{Ptr{$elty},StridedArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},StridedArray{$elty}}, incy::Integer) ccall(($(blasfunc(fname)), libblas), Void, (Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}), n, DX, incx, DY, incy) @@ -84,7 +84,7 @@ for (fname, elty) in ((:dscal_,:Float64), (:cscal_,:Complex64)) @eval begin # SUBROUTINE DSCAL(N,DA,DX,INCX) - function scal!(n::Integer, DA::$elty, DX::Union(Ptr{$elty},DenseArray{$elty}), incx::Integer) + function scal!(n::Integer, DA::$elty, DX::Union{Ptr{$elty},DenseArray{$elty}}, incx::Integer) ccall(($(blasfunc(fname)), libblas), Void, (Ref{BlasInt}, Ref{$elty}, Ptr{$elty}, Ref{BlasInt}), n, DA, DX, incx) @@ -104,7 +104,7 @@ for (fname, elty) in ((:ddot_,:Float64), # * .. # * .. Array Arguments .. # DOUBLE PRECISION DX(*),DY(*) - function dot(n::Integer, DX::Union(Ptr{$elty},DenseArray{$elty}), incx::Integer, DY::Union(Ptr{$elty},DenseArray{$elty}), incy::Integer) + function dot(n::Integer, DX::Union{Ptr{$elty},DenseArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},DenseArray{$elty}}, incy::Integer) ccall(($(blasfunc(fname)), libblas), $elty, (Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}), n, DX, incx, DY, incy) @@ -120,7 +120,7 @@ for (fname, elty) in ((:cblas_zdotc_sub,:Complex128), # * .. # * .. Array Arguments .. # DOUBLE PRECISION DX(*),DY(*) - function dotc(n::Integer, DX::Union(Ptr{$elty},DenseArray{$elty}), incx::Integer, DY::Union(Ptr{$elty},DenseArray{$elty}), incy::Integer) + function dotc(n::Integer, DX::Union{Ptr{$elty},DenseArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},DenseArray{$elty}}, incy::Integer) result = Ref{$elty}() ccall(($(blasfunc(fname)), libblas), Void, (BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ref{$elty}), @@ -138,7 +138,7 @@ for (fname, elty) in ((:cblas_zdotu_sub,:Complex128), # * .. # * .. Array Arguments .. # DOUBLE PRECISION DX(*),DY(*) - function dotu(n::Integer, DX::Union(Ptr{$elty},DenseArray{$elty}), incx::Integer, DY::Union(Ptr{$elty},DenseArray{$elty}), incy::Integer) + function dotu(n::Integer, DX::Union{Ptr{$elty},DenseArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},DenseArray{$elty}}, incy::Integer) result = Ref{$elty}() ccall(($(blasfunc(fname)), libblas), Void, (BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ref{$elty}), @@ -147,21 +147,21 @@ for (fname, elty) in ((:cblas_zdotu_sub,:Complex128), end end end -function dot{T<:BlasReal}(DX::Union(DenseArray{T},StridedVector{T}), DY::Union(DenseArray{T},StridedVector{T})) +function dot{T<:BlasReal}(DX::Union{DenseArray{T},StridedVector{T}}, DY::Union{DenseArray{T},StridedVector{T}}) n = length(DX) if n != length(DY) throw(DimensionMismatch("dot product arguments have lengths $(length(DX)) and $(length(DY))")) end dot(n, pointer(DX), stride(DX, 1), pointer(DY), stride(DY, 1)) end -function dotc{T<:BlasComplex}(DX::Union(DenseArray{T},StridedVector{T}), DY::Union(DenseArray{T},StridedVector{T})) +function dotc{T<:BlasComplex}(DX::Union{DenseArray{T},StridedVector{T}}, DY::Union{DenseArray{T},StridedVector{T}}) n = length(DX) if n != length(DY) throw(DimensionMismatch("dot product arguments have lengths $(length(DX)) and $(length(DY))")) end dotc(n, pointer(DX), stride(DX, 1), pointer(DY), stride(DY, 1)) end -function dotu{T<:BlasComplex}(DX::Union(DenseArray{T},StridedVector{T}), DY::Union(DenseArray{T},StridedVector{T})) +function dotu{T<:BlasComplex}(DX::Union{DenseArray{T},StridedVector{T}}, DY::Union{DenseArray{T},StridedVector{T}}) n = length(DX) if n != length(DY) throw(DimensionMismatch("dot product arguments have lengths $(length(DX)) and $(length(DY))")) @@ -176,7 +176,7 @@ for (fname, elty, ret_type) in ((:dnrm2_,:Float64,:Float64), (:scnrm2_,:Complex64,:Float32)) @eval begin # SUBROUTINE DNRM2(N,X,INCX) - function nrm2(n::Integer, X::Union(Ptr{$elty},DenseArray{$elty}), incx::Integer) + function nrm2(n::Integer, X::Union{Ptr{$elty},DenseArray{$elty}}, incx::Integer) ccall(($(blasfunc(fname)), libblas), $ret_type, (Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}), n, X, incx) @@ -193,7 +193,7 @@ for (fname, elty, ret_type) in ((:dasum_,:Float64,:Float64), (:scasum_,:Complex64,:Float32)) @eval begin # SUBROUTINE ASUM(N, X, INCX) - function asum(n::Integer, X::Union(Ptr{$elty},DenseArray{$elty}), incx::Integer) + function asum(n::Integer, X::Union{Ptr{$elty},DenseArray{$elty}}, incx::Integer) ccall(($(blasfunc(fname)), libblas), $ret_type, (Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}), n, X, incx) @@ -216,7 +216,7 @@ for (fname, elty) in ((:daxpy_,:Float64), # INTEGER INCX,INCY,N #* .. Array Arguments .. # DOUBLE PRECISION DX(*),DY(*) - function axpy!(n::Integer, alpha::($elty), dx::Union(Ptr{$elty}, DenseArray{$elty}), incx::Integer, dy::Union(Ptr{$elty}, DenseArray{$elty}), incy::Integer) + function axpy!(n::Integer, alpha::($elty), dx::Union{Ptr{$elty}, DenseArray{$elty}}, incx::Integer, dy::Union{Ptr{$elty}, DenseArray{$elty}}, incy::Integer) ccall(($(blasfunc(fname)), libblas), Void, (Ref{BlasInt}, Ref{$elty}, Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}), n, alpha, dx, incx, dy, incy) @@ -224,7 +224,7 @@ for (fname, elty) in ((:daxpy_,:Float64), end end end -function axpy!{T<:BlasFloat,Ta<:Number}(alpha::Ta, x::Union(DenseArray{T},StridedVector{T}), y::Union(DenseArray{T},StridedVector{T})) +function axpy!{T<:BlasFloat,Ta<:Number}(alpha::Ta, x::Union{DenseArray{T},StridedVector{T}}, y::Union{DenseArray{T},StridedVector{T}}) if length(x) != length(y) throw(DimensionMismatch("x has length $(length(x)), but y has length $(length(y))")) end @@ -232,8 +232,8 @@ function axpy!{T<:BlasFloat,Ta<:Number}(alpha::Ta, x::Union(DenseArray{T},Stride y end -function axpy!{T<:BlasFloat,Ta<:Number,Ti<:Integer}(alpha::Ta, x::Array{T}, rx::Union(UnitRange{Ti},Range{Ti}), - y::Array{T}, ry::Union(UnitRange{Ti},Range{Ti})) +function axpy!{T<:BlasFloat,Ta<:Number,Ti<:Integer}(alpha::Ta, x::Array{T}, rx::Union{UnitRange{Ti},Range{Ti}}, + y::Array{T}, ry::Union{UnitRange{Ti},Range{Ti}}) if length(rx) != length(ry) throw(DimensionMismatch("Ranges of differing lengths")) @@ -254,7 +254,7 @@ for (fname, elty) in ((:idamax_,:Float64), (:izamax_,:Complex128), (:icamax_,:Complex64)) @eval begin - function iamax(n::Integer, dx::Union(Ptr{$elty}, DenseArray{$elty}), incx::Integer) + function iamax(n::Integer, dx::Union{Ptr{$elty}, DenseArray{$elty}}, incx::Integer) ccall(($(blasfunc(fname)), libblas),BlasInt, (Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}), n, dx, incx) @@ -891,8 +891,8 @@ end end # module -function copy!{T<:BlasFloat,Ti<:Integer}(dest::Array{T}, rdest::Union(UnitRange{Ti},Range{Ti}), - src::Array{T}, rsrc::Union(UnitRange{Ti},Range{Ti})) +function copy!{T<:BlasFloat,Ti<:Integer}(dest::Array{T}, rdest::Union{UnitRange{Ti},Range{Ti}}, + src::Array{T}, rsrc::Union{UnitRange{Ti},Range{Ti}}) if minimum(rdest) < 1 || maximum(rdest) > length(dest) throw(BoundsError("Range out of bounds for dest, of length $(length(dest))")) end diff --git a/base/linalg/cholesky.jl b/base/linalg/cholesky.jl index e4b40d8a64294..38e610c6959f4 100644 --- a/base/linalg/cholesky.jl +++ b/base/linalg/cholesky.jl @@ -79,7 +79,7 @@ function chol{T}(A::AbstractMatrix{T}) S = promote_type(typeof(chol(one(T))), Float32) chol!(copy_oftype(A, S)) end -function chol{T}(A::AbstractMatrix{T}, uplo::Union(Type{Val{:L}}, Type{Val{:U}})) +function chol{T}(A::AbstractMatrix{T}, uplo::Union{Type{Val{:L}}, Type{Val{:U}}}) S = promote_type(typeof(chol(one(T))), Float32) chol!(copy_oftype(A, S), uplo) end @@ -93,7 +93,7 @@ function chol!(x::Number, uplo) end chol(x::Number, uplo::Symbol=:U) = chol!(x, uplo) -cholfact!{T<:BlasFloat}(A::StridedMatrix{T}, uplo::Symbol=:U, pivot::Union(Type{Val{false}}, Type{Val{true}})=Val{false}; tol=0.0) = +cholfact!{T<:BlasFloat}(A::StridedMatrix{T}, uplo::Symbol=:U, pivot::Union{Type{Val{false}}, Type{Val{true}}}=Val{false}; tol=0.0) = _cholfact!(A, pivot, uplo, tol=tol) function _cholfact!{T<:BlasFloat}(A::StridedMatrix{T}, ::Type{Val{false}}, uplo::Symbol=:U; tol=0.0) return Cholesky(chol!(A, Val{uplo}).data, uplo) @@ -103,7 +103,7 @@ function _cholfact!{T<:BlasFloat}(A::StridedMatrix{T}, ::Type{Val{true}}, uplo:: A, piv, rank, info = LAPACK.pstrf!(uplochar, A, tol) return CholeskyPivoted{T,StridedMatrix{T}}(A, uplochar, piv, rank, tol, info) end -cholfact!(A::StridedMatrix, uplo::Symbol=:U, pivot::Union(Type{Val{false}}, Type{Val{true}})=Val{false}; tol=0.0) = Cholesky(chol!(A, Val{uplo}).data, uplo) +cholfact!(A::StridedMatrix, uplo::Symbol=:U, pivot::Union{Type{Val{false}}, Type{Val{true}}}=Val{false}; tol=0.0) = Cholesky(chol!(A, Val{uplo}).data, uplo) # function cholfact!{T<:BlasFloat,S}(C::Cholesky{T,S}) # _, info = LAPACK.potrf!(C.uplo, C.factors) @@ -111,11 +111,11 @@ cholfact!(A::StridedMatrix, uplo::Symbol=:U, pivot::Union(Type{Val{false}}, Type # C # end -# cholfact{T<:BlasFloat}(A::StridedMatrix{T}, uplo::Symbol=:U, pivot::Union(Type{Val{false}}, Type{Val{true}})=Val{false}; tol=0.0) = +# cholfact{T<:BlasFloat}(A::StridedMatrix{T}, uplo::Symbol=:U, pivot::Union{Type{Val{false}}, Type{Val{true}}}=Val{false}; tol=0.0) = # cholfact!(copy(A), uplo, pivot, tol=tol) -cholfact{T}(A::StridedMatrix{T}, uplo::Symbol=:U, pivot::Union(Type{Val{false}}, Type{Val{true}})=Val{false}; tol=0.0) = +cholfact{T}(A::StridedMatrix{T}, uplo::Symbol=:U, pivot::Union{Type{Val{false}}, Type{Val{true}}}=Val{false}; tol=0.0) = cholfact!(copy_oftype(A, promote_type(typeof(chol(one(T))),Float32)), uplo, pivot; tol = tol) # _cholfact{T<:BlasFloat}(A::StridedMatrix{T}, pivot::Type{Val{true}}, uplo::Symbol=:U; tol=0.0) = # cholfact!(A, uplo, pivot, tol = tol) @@ -151,8 +151,8 @@ full(F::CholeskyPivoted) = (ip=invperm(F[:p]); (F[:L] * F[:U])[ip,ip]) copy(C::Cholesky) = Cholesky(copy(C.factors), C.uplo) copy(C::CholeskyPivoted) = CholeskyPivoted(copy(C.factors), C.uplo, C.piv, C.rank, C.tol, C.info) -size(C::Union(Cholesky, CholeskyPivoted)) = size(C.factors) -size(C::Union(Cholesky, CholeskyPivoted), d::Integer) = size(C.factors, d) +size(C::Union{Cholesky, CholeskyPivoted}) = size(C.factors) +size(C::Union{Cholesky, CholeskyPivoted}, d::Integer) = size(C.factors, d) function getindex{T,S}(C::Cholesky{T,S}, d::Symbol) d == :U && return UpperTriangular(symbol(C.uplo) == d ? C.factors : C.factors') diff --git a/base/linalg/dense.jl b/base/linalg/dense.jl index b50e12f82f230..feeec01faef8e 100644 --- a/base/linalg/dense.jl +++ b/base/linalg/dense.jl @@ -38,34 +38,34 @@ stride1(x::StridedVector) = stride(x, 1)::Int import Base: mapreduce_seq_impl, AbsFun, Abs2Fun, AddFun -mapreduce_seq_impl{T<:BlasReal}(::AbsFun, ::AddFun, a::Union(Array{T},StridedVector{T}), ifirst::Int, ilast::Int) = +mapreduce_seq_impl{T<:BlasReal}(::AbsFun, ::AddFun, a::Union{Array{T},StridedVector{T}}, ifirst::Int, ilast::Int) = BLAS.asum(ilast-ifirst+1, pointer(a, ifirst), stride1(a)) -function mapreduce_seq_impl{T<:BlasReal}(::Abs2Fun, ::AddFun, a::Union(Array{T},StridedVector{T}), ifirst::Int, ilast::Int) +function mapreduce_seq_impl{T<:BlasReal}(::Abs2Fun, ::AddFun, a::Union{Array{T},StridedVector{T}}, ifirst::Int, ilast::Int) n = ilast-ifirst+1 px = pointer(a, ifirst) incx = stride1(a) BLAS.dot(n, px, incx, px, incx) end -function mapreduce_seq_impl{T<:BlasComplex}(::Abs2Fun, ::AddFun, a::Union(Array{T},StridedVector{T}), ifirst::Int, ilast::Int) +function mapreduce_seq_impl{T<:BlasComplex}(::Abs2Fun, ::AddFun, a::Union{Array{T},StridedVector{T}}, ifirst::Int, ilast::Int) n = ilast-ifirst+1 px = pointer(a, ifirst) incx = stride1(a) real(BLAS.dotc(n, px, incx, px, incx)) end -function norm{T<:BlasFloat, TI<:Integer}(x::StridedVector{T}, rx::Union(UnitRange{TI},Range{TI})) +function norm{T<:BlasFloat, TI<:Integer}(x::StridedVector{T}, rx::Union{UnitRange{TI},Range{TI}}) if minimum(rx) < 1 || maximum(rx) > length(x) throw(BoundsError()) end BLAS.nrm2(length(rx), pointer(x)+(first(rx)-1)*sizeof(T), step(rx)) end -vecnorm1{T<:BlasReal}(x::Union(Array{T},StridedVector{T})) = +vecnorm1{T<:BlasReal}(x::Union{Array{T},StridedVector{T}}) = length(x) < ASUM_CUTOFF ? generic_vecnorm1(x) : BLAS.asum(x) -vecnorm2{T<:BlasFloat}(x::Union(Array{T},StridedVector{T})) = +vecnorm2{T<:BlasFloat}(x::Union{Array{T},StridedVector{T}}) = length(x) < NRM2_CUTOFF ? generic_vecnorm2(x) : BLAS.nrm2(x) function triu!(M::AbstractMatrix, k::Integer) @@ -161,8 +161,8 @@ function kron{T,S}(a::Matrix{T}, b::Matrix{S}) R end -kron(a::Number, b::Union(Number, Vector, Matrix)) = a * b -kron(a::Union(Vector, Matrix), b::Number) = a * b +kron(a::Number, b::Union{Number, Vector, Matrix}) = a * b +kron(a::Union{Vector, Matrix}, b::Number) = a * b kron(a::Vector, b::Vector)=vec(kron(reshape(a,length(a),1),reshape(b,length(b),1))) kron(a::Matrix, b::Vector)=kron(a,reshape(b,length(b),1)) kron(a::Vector, b::Matrix)=kron(reshape(a,length(a),1),b) diff --git a/base/linalg/eigen.jl b/base/linalg/eigen.jl index 70527b1d5fbb5..0c33ba27398e6 100644 --- a/base/linalg/eigen.jl +++ b/base/linalg/eigen.jl @@ -17,13 +17,13 @@ end GeneralizedEigen{T,V}(values::AbstractVector{V}, vectors::AbstractMatrix{T}) = GeneralizedEigen{T,V,typeof(vectors),typeof(values)}(values, vectors) -function getindex(A::Union(Eigen,GeneralizedEigen), d::Symbol) +function getindex(A::Union{Eigen,GeneralizedEigen}, d::Symbol) d == :values && return A.values d == :vectors && return A.vectors throw(KeyError(d)) end -isposdef(A::Union(Eigen,GeneralizedEigen)) = all(A.values .> 0) +isposdef(A::Union{Eigen,GeneralizedEigen}) = all(A.values .> 0) function eigfact!{T<:BlasReal}(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) n = size(A, 2) @@ -58,16 +58,16 @@ function eigfact{T}(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) end eigfact(x::Number) = Eigen([x], fill(one(x), 1, 1)) -# function eig(A::Union(Number, AbstractMatrix); permute::Bool=true, scale::Bool=true) +# function eig(A::Union{Number, AbstractMatrix}; permute::Bool=true, scale::Bool=true) # F = eigfact(A, permute=permute, scale=scale) # F[:values], F[:vectors] # end -function eig(A::Union(Number, AbstractMatrix), args...; kwargs...) +function eig(A::Union{Number, AbstractMatrix}, args...; kwargs...) F = eigfact(A, args...; kwargs...) F[:values], F[:vectors] end #Calculates eigenvectors -eigvecs(A::Union(Number, AbstractMatrix), args...; kwargs...) = eigfact(A, args...; kwargs...)[:vectors] +eigvecs(A::Union{Number, AbstractMatrix}, args...; kwargs...) = eigfact(A, args...; kwargs...)[:vectors] function eigvals!{T<:BlasReal}(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true) issym(A) && return eigvals!(Symmetric(A)) @@ -88,11 +88,11 @@ function eigvals{T<:Number}(x::T; kwargs...) end #Computes maximum and minimum eigenvalue -function eigmax(A::Union(Number, StridedMatrix); permute::Bool=true, scale::Bool=true) +function eigmax(A::Union{Number, StridedMatrix}; permute::Bool=true, scale::Bool=true) v = eigvals(A, permute = permute, scale = scale) iseltype(v,Complex) ? error("DomainError: complex eigenvalues cannot be ordered") : maximum(v) end -function eigmin(A::Union(Number, StridedMatrix); permute::Bool=true, scale::Bool=true) +function eigmin(A::Union{Number, StridedMatrix}; permute::Bool=true, scale::Bool=true) v = eigvals(A, permute = permute, scale = scale) iseltype(v,Complex) ? error("DomainError: complex eigenvalues cannot be ordered") : minimum(v) end diff --git a/base/linalg/lu.jl b/base/linalg/lu.jl index a7c73f20e7325..c1cb770515e79 100644 --- a/base/linalg/lu.jl +++ b/base/linalg/lu.jl @@ -12,12 +12,12 @@ end LU{T}(factors::AbstractMatrix{T}, ipiv::Vector{BlasInt}, info::BlasInt) = LU{T,typeof(factors)}(factors, ipiv, info) # StridedMatrix -function lufact!{T<:BlasFloat}(A::StridedMatrix{T}, pivot::Union(Type{Val{false}}, Type{Val{true}}) = Val{true}) +function lufact!{T<:BlasFloat}(A::StridedMatrix{T}, pivot::Union{Type{Val{false}}, Type{Val{true}}} = Val{true}) pivot==Val{false} && return generic_lufact!(A, pivot) lpt = LAPACK.getrf!(A) return LU{T,typeof(A)}(lpt[1], lpt[2], lpt[3]) end -lufact!(A::StridedMatrix, pivot::Union(Type{Val{false}}, Type{Val{true}}) = Val{true}) = generic_lufact!(A, pivot) +lufact!(A::StridedMatrix, pivot::Union{Type{Val{false}}, Type{Val{true}}} = Val{true}) = generic_lufact!(A, pivot) function generic_lufact!{T,Pivot}(A::StridedMatrix{T}, ::Type{Val{Pivot}} = Val{true}) m, n = size(A) minmn = min(m,n) @@ -67,10 +67,10 @@ function generic_lufact!{T,Pivot}(A::StridedMatrix{T}, ::Type{Val{Pivot}} = Val{ end # floating point types doesn't have to be promoted for LU, but should default to pivoting -lufact{T<:FloatingPoint}(A::Union(AbstractMatrix{T},AbstractMatrix{Complex{T}}), pivot::Union(Type{Val{false}}, Type{Val{true}}) = Val{true}) = lufact!(copy(A), pivot) +lufact{T<:FloatingPoint}(A::Union{AbstractMatrix{T},AbstractMatrix{Complex{T}}}, pivot::Union{Type{Val{false}}, Type{Val{true}}} = Val{true}) = lufact!(copy(A), pivot) # for all other types we must promote to a type which is stable under division -function lufact{T}(A::AbstractMatrix{T}, pivot::Union(Type{Val{false}}, Type{Val{true}})) +function lufact{T}(A::AbstractMatrix{T}, pivot::Union{Type{Val{false}}, Type{Val{true}}}) S = typeof(zero(T)/one(T)) lufact!(copy_oftype(A, S), pivot) end @@ -89,7 +89,7 @@ lufact(x::Number) = LU(fill(x, 1, 1), BlasInt[1], x == 0 ? one(BlasInt) : zero(B lufact(F::LU) = F lu(x::Number) = (one(x), x, 1) -function lu(A::AbstractMatrix, pivot::Union(Type{Val{false}}, Type{Val{true}}) = Val{true}) +function lu(A::AbstractMatrix, pivot::Union{Type{Val{false}}, Type{Val{true}}} = Val{true}) F = lufact(A, pivot) F[:L], F[:U], F[:p] end @@ -194,7 +194,7 @@ cond(A::LU, p::Number) = norm(A[:L]*A[:U],p)*norm(inv(A),p) # Tridiagonal # See dgttrf.f -function lufact!{T}(A::Tridiagonal{T}, pivot::Union(Type{Val{false}}, Type{Val{true}}) = Val{true}) +function lufact!{T}(A::Tridiagonal{T}, pivot::Union{Type{Val{false}}, Type{Val{true}}} = Val{true}) n = size(A, 1) info = 0 ipiv = Array(BlasInt, n) diff --git a/base/linalg/matmul.jl b/base/linalg/matmul.jl index d4f304bab23fa..e252c67fc662c 100644 --- a/base/linalg/matmul.jl +++ b/base/linalg/matmul.jl @@ -37,16 +37,16 @@ scale(b::Vector, A::Matrix) = scale!(similar(b, promote_type(eltype(A),eltype(b) # Dot products -vecdot{T<:BlasReal}(x::Union(DenseArray{T},StridedVector{T}), y::Union(DenseArray{T},StridedVector{T})) = BLAS.dot(x, y) -vecdot{T<:BlasComplex}(x::Union(DenseArray{T},StridedVector{T}), y::Union(DenseArray{T},StridedVector{T})) = BLAS.dotc(x, y) -function dot{T<:BlasReal, TI<:Integer}(x::Vector{T}, rx::Union(UnitRange{TI},Range{TI}), y::Vector{T}, ry::Union(UnitRange{TI},Range{TI})) +vecdot{T<:BlasReal}(x::Union{DenseArray{T},StridedVector{T}}, y::Union{DenseArray{T},StridedVector{T}}) = BLAS.dot(x, y) +vecdot{T<:BlasComplex}(x::Union{DenseArray{T},StridedVector{T}}, y::Union{DenseArray{T},StridedVector{T}}) = BLAS.dotc(x, y) +function dot{T<:BlasReal, TI<:Integer}(x::Vector{T}, rx::Union{UnitRange{TI},Range{TI}}, y::Vector{T}, ry::Union{UnitRange{TI},Range{TI}}) length(rx)==length(ry) || throw(DimensionMismatch()) if minimum(rx) < 1 || maximum(rx) > length(x) || minimum(ry) < 1 || maximum(ry) > length(y) throw(BoundsError()) end BLAS.dot(length(rx), pointer(x)+(first(rx)-1)*sizeof(T), step(rx), pointer(y)+(first(ry)-1)*sizeof(T), step(ry)) end -function dot{T<:BlasComplex, TI<:Integer}(x::Vector{T}, rx::Union(UnitRange{TI},Range{TI}), y::Vector{T}, ry::Union(UnitRange{TI},Range{TI})) +function dot{T<:BlasComplex, TI<:Integer}(x::Vector{T}, rx::Union{UnitRange{TI},Range{TI}}, y::Vector{T}, ry::Union{UnitRange{TI},Range{TI}}) length(rx)==length(ry) || throw(DimensionMismatch()) if minimum(rx) < 1 || maximum(rx) > length(x) || minimum(ry) < 1 || maximum(ry) > length(y) throw(BoundsError()) @@ -245,7 +245,7 @@ function syrk_wrapper!{T<:BlasFloat}(C::StridedMatrix{T}, tA::Char, A::StridedVe return generic_matmatmul!(C, tA, tAt, A, A) end -function herk_wrapper!{T<:BlasReal}(C::Union(StridedMatrix{T}, StridedMatrix{Complex{T}}), tA::Char, A::Union(StridedVecOrMat{T}, StridedVecOrMat{Complex{T}})) +function herk_wrapper!{T<:BlasReal}(C::Union{StridedMatrix{T}, StridedMatrix{Complex{T}}}, tA::Char, A::Union{StridedVecOrMat{T}, StridedVecOrMat{Complex{T}}}) nC = chksquare(C) if tA == 'C' (nA, mA) = size(A,1), size(A,2) diff --git a/base/linalg/qr.jl b/base/linalg/qr.jl index 83fe4e35ecd12..245e600e2d675 100644 --- a/base/linalg/qr.jl +++ b/base/linalg/qr.jl @@ -24,7 +24,7 @@ immutable QRPivoted{T,S<:AbstractMatrix} <: Factorization{T} end QRPivoted{T}(factors::AbstractMatrix{T}, τ::Vector{T}, jpvt::Vector{BlasInt}) = QRPivoted{T,typeof(factors)}(factors, τ, jpvt) -function qrfact!{T}(A::AbstractMatrix{T}, pivot::Union(Type{Val{false}}, Type{Val{true}})=Val{false}) +function qrfact!{T}(A::AbstractMatrix{T}, pivot::Union{Type{Val{false}}, Type{Val{true}}}=Val{false}) pivot==Val{true} && warn("pivoting only implemented for Float32, Float64, Complex64 and Complex128") m, n = size(A) τ = zeros(T, min(m,n)) @@ -49,19 +49,19 @@ function qrfact!{T}(A::AbstractMatrix{T}, pivot::Union(Type{Val{false}}, Type{Va end qrfact!{T<:BlasFloat}(A::StridedMatrix{T}, pivot::Type{Val{false}} = Val{false}) = QRCompactWY(LAPACK.geqrt!(A, min(minimum(size(A)), 36))...) qrfact!{T<:BlasFloat}(A::StridedMatrix{T}, pivot::Type{Val{true}}) = QRPivoted(LAPACK.geqp3!(A)...) -qrfact{T<:BlasFloat}(A::StridedMatrix{T}, pivot::Union(Type{Val{false}}, Type{Val{true}})=Val{false}) = qrfact!(copy(A), pivot) +qrfact{T<:BlasFloat}(A::StridedMatrix{T}, pivot::Union{Type{Val{false}}, Type{Val{true}}}=Val{false}) = qrfact!(copy(A), pivot) copy_oftype{T}(A::StridedMatrix{T}, ::Type{T}) = copy(A) copy_oftype{T,S}(A::StridedMatrix{T}, ::Type{S}) = convert(AbstractMatrix{S}, A) -qrfact{T}(A::StridedMatrix{T}, pivot::Union(Type{Val{false}}, Type{Val{true}})=Val{false}) = qrfact!(copy_oftype(A, typeof(one(T)/norm(one(T)))), pivot) +qrfact{T}(A::StridedMatrix{T}, pivot::Union{Type{Val{false}}, Type{Val{true}}}=Val{false}) = qrfact!(copy_oftype(A, typeof(one(T)/norm(one(T)))), pivot) qrfact(x::Number) = qrfact(fill(x,1,1)) -qr(A::Union(Number, AbstractMatrix), pivot::Union(Type{Val{false}}, Type{Val{true}})=Val{false}; thin::Bool=true) = +qr(A::Union{Number, AbstractMatrix}, pivot::Union{Type{Val{false}}, Type{Val{true}}}=Val{false}; thin::Bool=true) = _qr(A, pivot, thin=thin) -function _qr(A::Union(Number, AbstractMatrix), ::Type{Val{false}}; thin::Bool=true) +function _qr(A::Union{Number, AbstractMatrix}, ::Type{Val{false}}; thin::Bool=true) F = qrfact(A, Val{false}) full(getq(F), thin=thin), F[:R]::Matrix{eltype(F)} end -function _qr(A::Union(Number, AbstractMatrix), ::Type{Val{true}}; thin::Bool=true) +function _qr(A::Union{Number, AbstractMatrix}, ::Type{Val{true}}; thin::Bool=true) F = qrfact(A, Val{true}) full(getq(F), thin=thin), F[:R]::Matrix{eltype(F)}, F[:p]::Vector{BlasInt} end @@ -116,7 +116,7 @@ end # Type-stable interface to get Q getq(A::QRCompactWY) = QRCompactWYQ(A.factors,A.T) -getq(A::Union(QR, QRPivoted)) = QRPackedQ(A.factors,A.τ) +getq(A::Union{QR, QRPivoted}) = QRPackedQ(A.factors,A.τ) immutable QRPackedQ{T,S<:AbstractMatrix} <: AbstractMatrix{T} factors::S @@ -144,12 +144,12 @@ convert{T}(::Type{AbstractMatrix{T}}, Q::QRPackedQ) = convert(QRPackedQ{T}, Q) convert{S}(::Type{QRCompactWYQ{S}}, Q::QRCompactWYQ) = QRCompactWYQ(convert(AbstractMatrix{S}, Q.factors), convert(AbstractMatrix{S}, Q.T)) convert{S}(::Type{AbstractMatrix{S}}, Q::QRCompactWYQ) = convert(QRCompactWYQ{S}, Q) -size(A::Union(QR,QRCompactWY,QRPivoted), dim::Integer) = size(A.factors, dim) -size(A::Union(QR,QRCompactWY,QRPivoted)) = size(A.factors) -size(A::Union(QRPackedQ,QRCompactWYQ), dim::Integer) = 0 < dim ? (dim <= 2 ? size(A.factors, 1) : 1) : throw(BoundsError()) -size(A::Union(QRPackedQ,QRCompactWYQ)) = size(A, 1), size(A, 2) +size(A::Union{QR,QRCompactWY,QRPivoted}, dim::Integer) = size(A.factors, dim) +size(A::Union{QR,QRCompactWY,QRPivoted}) = size(A.factors) +size(A::Union{QRPackedQ,QRCompactWYQ}, dim::Integer) = 0 < dim ? (dim <= 2 ? size(A.factors, 1) : 1) : throw(BoundsError()) +size(A::Union{QRPackedQ,QRCompactWYQ}) = size(A, 1), size(A, 2) -full{T}(A::Union(QRPackedQ{T},QRCompactWYQ{T}); thin::Bool=true) = A_mul_B!(A, thin ? eye(T, size(A.factors,1), minimum(size(A.factors))) : eye(T, size(A.factors,1))) +full{T}(A::Union{QRPackedQ{T},QRCompactWYQ{T}}; thin::Bool=true) = A_mul_B!(A, thin ? eye(T, size(A.factors,1), minimum(size(A.factors))) : eye(T, size(A.factors,1))) ## Multiplication by Q ### QB @@ -180,7 +180,7 @@ function A_mul_B!{T}(A::QRPackedQ{T}, B::AbstractVecOrMat{T}) B end -function (*){TA,Tb}(A::Union(QRPackedQ{TA},QRCompactWYQ{TA}), b::StridedVector{Tb}) +function (*){TA,Tb}(A::Union{QRPackedQ{TA},QRCompactWYQ{TA}}, b::StridedVector{Tb}) TAb = promote_type(TA, Tb) Anew = convert(AbstractMatrix{TAb}, A) if size(A.factors, 1) == length(b) @@ -192,7 +192,7 @@ function (*){TA,Tb}(A::Union(QRPackedQ{TA},QRCompactWYQ{TA}), b::StridedVector{T end A_mul_B!(Anew, bnew) end -function (*){TA,TB}(A::Union(QRPackedQ{TA},QRCompactWYQ{TA}), B::StridedMatrix{TB}) +function (*){TA,TB}(A::Union{QRPackedQ{TA},QRCompactWYQ{TA}}, B::StridedMatrix{TB}) TAB = promote_type(TA, TB) Anew = convert(AbstractMatrix{TAB}, A) if size(A.factors, 1) == size(B, 1) @@ -234,7 +234,7 @@ function Ac_mul_B!{T}(A::QRPackedQ{T}, B::AbstractVecOrMat{T}) end B end -function Ac_mul_B{TQ<:Number,TB<:Number,N}(Q::Union(QRPackedQ{TQ},QRCompactWYQ{TQ}), B::StridedArray{TB,N}) +function Ac_mul_B{TQ<:Number,TB<:Number,N}(Q::Union{QRPackedQ{TQ},QRCompactWYQ{TQ}}, B::StridedArray{TB,N}) TQB = promote_type(TQ,TB) return Ac_mul_B!(convert(AbstractMatrix{TQB}, Q), copy_oftype(B, TQB)) end @@ -267,7 +267,7 @@ function A_mul_B!{T}(A::StridedMatrix{T},Q::QRPackedQ{T}) A end -function (*){TA,TQ,N}(A::StridedArray{TA,N}, Q::Union(QRPackedQ{TQ},QRCompactWYQ{TQ})) +function (*){TA,TQ,N}(A::StridedArray{TA,N}, Q::Union{QRPackedQ{TQ},QRCompactWYQ{TQ}}) TAQ = promote_type(TA, TQ) return A_mul_B!(copy_oftype(A, TAQ), convert(AbstractMatrix{TAQ}, Q)) end @@ -301,8 +301,8 @@ function A_mul_Bc!{T}(A::AbstractMatrix{T},Q::QRPackedQ{T}) end A end -A_mul_Bc(A::AbstractTriangular, B::Union(QRCompactWYQ,QRPackedQ)) = A_mul_Bc(full(A), B) -function A_mul_Bc{TA,TB}(A::AbstractArray{TA}, B::Union(QRCompactWYQ{TB},QRPackedQ{TB})) +A_mul_Bc(A::AbstractTriangular, B::Union{QRCompactWYQ,QRPackedQ}) = A_mul_Bc(full(A), B) +function A_mul_Bc{TA,TB}(A::AbstractArray{TA}, B::Union{QRCompactWYQ{TB},QRPackedQ{TB}}) TAB = promote_type(TA,TB) BB = convert(AbstractMatrix{TAB}, B) if size(A,2) == size(B.factors, 1) @@ -412,7 +412,7 @@ function A_ldiv_B!(A::QRPivoted, B::StridedMatrix) B[1:size(A.factors, 2),:] = sub(B, 1:size(A.factors, 2), :)[invperm(A.jpvt)] B end -function \{TA,Tb}(A::Union(QR{TA},QRCompactWY{TA},QRPivoted{TA}), b::StridedVector{Tb}) +function \{TA,Tb}(A::Union{QR{TA},QRCompactWY{TA},QRPivoted{TA}}, b::StridedVector{Tb}) S = promote_type(TA,Tb) m,n = size(A) m == length(b) || throw(DimensionMismatch("left hand side has $m rows, but right hand side has length $(length(b))")) @@ -424,7 +424,7 @@ function \{TA,Tb}(A::Union(QR{TA},QRCompactWY{TA},QRPivoted{TA}), b::StridedVect end return length(x) > n ? x[1:n] : x end -function \{TA,TB}(A::Union(QR{TA},QRCompactWY{TA},QRPivoted{TA}),B::StridedMatrix{TB}) +function \{TA,TB}(A::Union{QR{TA},QRCompactWY{TA},QRPivoted{TA}},B::StridedMatrix{TB}) S = promote_type(TA,TB) m,n = size(A) m == size(B,1) || throw(DimensionMismatch("left hand side has $m rows, but right hand side has $(size(B,1)) rows")) @@ -474,7 +474,7 @@ function getindex(A::Hessenberg, d::Symbol) end # Also printing of QRQs -getindex(A::Union(QRPackedQ,QRCompactWYQ,HessenbergQ), i::Integer, j::Integer) = (x = zeros(eltype(A), size(A, 1)); x[i] = 1; y = zeros(eltype(A), size(A, 2)); y[j] = 1; dot(x, A*y)) +getindex(A::Union{QRPackedQ,QRCompactWYQ,HessenbergQ}, i::Integer, j::Integer) = (x = zeros(eltype(A), size(A, 1)); x[i] = 1; y = zeros(eltype(A), size(A, 2)); y[j] = 1; dot(x, A*y)) ## reconstruct the original matrix full(F::QR) = F[:Q] * F[:R] diff --git a/base/linalg/schur.jl b/base/linalg/schur.jl index 5c7204ee1ff96..fef129e5c4311 100644 --- a/base/linalg/schur.jl +++ b/base/linalg/schur.jl @@ -33,10 +33,10 @@ function schur(A::StridedMatrix) SchurF[:T], SchurF[:Z], SchurF[:values] end -ordschur!{Ty<:BlasFloat}(Q::StridedMatrix{Ty}, T::StridedMatrix{Ty}, select::Union(Vector{Bool},BitVector)) = Schur(LinAlg.LAPACK.trsen!(convert(Vector{BlasInt}, select), T , Q)...) -ordschur{Ty<:BlasFloat}(Q::StridedMatrix{Ty}, T::StridedMatrix{Ty}, select::Union(Vector{Bool},BitVector)) = ordschur!(copy(Q), copy(T), select) -ordschur!{Ty<:BlasFloat}(schur::Schur{Ty}, select::Union(Vector{Bool},BitVector)) = (res=ordschur!(schur.Z, schur.T, select); schur[:values][:]=res[:values]; res) -ordschur{Ty<:BlasFloat}(schur::Schur{Ty}, select::Union(Vector{Bool},BitVector)) = ordschur(schur.Z, schur.T, select) +ordschur!{Ty<:BlasFloat}(Q::StridedMatrix{Ty}, T::StridedMatrix{Ty}, select::Union{Vector{Bool},BitVector}) = Schur(LinAlg.LAPACK.trsen!(convert(Vector{BlasInt}, select), T , Q)...) +ordschur{Ty<:BlasFloat}(Q::StridedMatrix{Ty}, T::StridedMatrix{Ty}, select::Union{Vector{Bool},BitVector}) = ordschur!(copy(Q), copy(T), select) +ordschur!{Ty<:BlasFloat}(schur::Schur{Ty}, select::Union{Vector{Bool},BitVector}) = (res=ordschur!(schur.Z, schur.T, select); schur[:values][:]=res[:values]; res) +ordschur{Ty<:BlasFloat}(schur::Schur{Ty}, select::Union{Vector{Bool},BitVector}) = ordschur(schur.Z, schur.T, select) immutable GeneralizedSchur{Ty<:BlasFloat, M<:AbstractMatrix} <: Factorization{Ty} S::M @@ -56,10 +56,10 @@ function schurfact{TA,TB}(A::StridedMatrix{TA}, B::StridedMatrix{TB}) return schurfact!(copy_oftype(A, S), copy_oftype(B, S)) end -ordschur!{Ty<:BlasFloat}(S::StridedMatrix{Ty}, T::StridedMatrix{Ty}, Q::StridedMatrix{Ty}, Z::StridedMatrix{Ty}, select::Union(Vector{Bool},BitVector)) = GeneralizedSchur(LinAlg.LAPACK.tgsen!(convert(Vector{BlasInt}, select), S, T, Q, Z)...) -ordschur{Ty<:BlasFloat}(S::StridedMatrix{Ty}, T::StridedMatrix{Ty}, Q::StridedMatrix{Ty}, Z::StridedMatrix{Ty}, select::Union(Vector{Bool},BitVector)) = ordschur!(copy(S), copy(T), copy(Q), copy(Z), select) -ordschur!{Ty<:BlasFloat}(gschur::GeneralizedSchur{Ty}, select::Union(Vector{Bool},BitVector)) = (res=ordschur!(gschur.S, gschur.T, gschur.Q, gschur.Z, select); gschur[:alpha][:]=res[:alpha]; gschur[:beta][:]=res[:beta]; res) -ordschur{Ty<:BlasFloat}(gschur::GeneralizedSchur{Ty}, select::Union(Vector{Bool},BitVector)) = ordschur(gschur.S, gschur.T, gschur.Q, gschur.Z, select) +ordschur!{Ty<:BlasFloat}(S::StridedMatrix{Ty}, T::StridedMatrix{Ty}, Q::StridedMatrix{Ty}, Z::StridedMatrix{Ty}, select::Union{Vector{Bool},BitVector}) = GeneralizedSchur(LinAlg.LAPACK.tgsen!(convert(Vector{BlasInt}, select), S, T, Q, Z)...) +ordschur{Ty<:BlasFloat}(S::StridedMatrix{Ty}, T::StridedMatrix{Ty}, Q::StridedMatrix{Ty}, Z::StridedMatrix{Ty}, select::Union{Vector{Bool},BitVector}) = ordschur!(copy(S), copy(T), copy(Q), copy(Z), select) +ordschur!{Ty<:BlasFloat}(gschur::GeneralizedSchur{Ty}, select::Union{Vector{Bool},BitVector}) = (res=ordschur!(gschur.S, gschur.T, gschur.Q, gschur.Z, select); gschur[:alpha][:]=res[:alpha]; gschur[:beta][:]=res[:beta]; res) +ordschur{Ty<:BlasFloat}(gschur::GeneralizedSchur{Ty}, select::Union{Vector{Bool},BitVector}) = ordschur(gschur.S, gschur.T, gschur.Q, gschur.Z, select) function getindex(F::GeneralizedSchur, d::Symbol) if d == :S diff --git a/base/linalg/special.jl b/base/linalg/special.jl index 76e0d8f094cd4..9e86396b7430b 100644 --- a/base/linalg/special.jl +++ b/base/linalg/special.jl @@ -22,7 +22,7 @@ function convert(::Type{UnitLowerTriangular}, A::Diagonal) UnitLowerTriangular(full(A)) end -function convert(::Type{Diagonal}, A::Union(Bidiagonal, SymTridiagonal)) +function convert(::Type{Diagonal}, A::Union{Bidiagonal, SymTridiagonal}) all(A.ev .== 0) || throw(ArgumentError("Matrix cannot be represented as Diagonal")) Diagonal(A.dv) end @@ -127,5 +127,5 @@ end A_mul_Bc!(A::AbstractTriangular, B::QRCompactWYQ) = A_mul_Bc!(full!(A),B) A_mul_Bc!(A::AbstractTriangular, B::QRPackedQ) = A_mul_Bc!(full!(A),B) -A_mul_Bc(A::AbstractTriangular, B::Union(QRCompactWYQ,QRPackedQ)) = A_mul_Bc(full(A), B) +A_mul_Bc(A::AbstractTriangular, B::Union{QRCompactWYQ,QRPackedQ}) = A_mul_Bc(full(A), B) diff --git a/base/linalg/svd.jl b/base/linalg/svd.jl index 0afc9c9d599eb..6d038cc610208 100644 --- a/base/linalg/svd.jl +++ b/base/linalg/svd.jl @@ -25,7 +25,7 @@ end svdfact(x::Number; thin::Bool=true) = SVD(x == 0 ? fill(one(x), 1, 1) : fill(x/abs(x), 1, 1), [abs(x)], fill(one(x), 1, 1)) svdfact(x::Integer; thin::Bool=true) = svdfact(float(x), thin=thin) -function svd(A::Union(Number, AbstractArray); thin::Bool=true) +function svd(A::Union{Number, AbstractArray}; thin::Bool=true) F = svdfact(A, thin=thin) F.U, F.S, F.Vt' end diff --git a/base/linalg/symmetric.jl b/base/linalg/symmetric.jl index 2fa2772356735..6b3bd6c46b186 100644 --- a/base/linalg/symmetric.jl +++ b/base/linalg/symmetric.jl @@ -19,8 +19,8 @@ function Hermitian(A::AbstractMatrix, uplo::Symbol=:U) Hermitian{eltype(A),typeof(A)}(A, char_uplo(uplo)) end -typealias HermOrSym{T,S} Union(Hermitian{T,S}, Symmetric{T,S}) -typealias RealHermSymComplexHerm{T<:Real,S} Union(Hermitian{T,S}, Symmetric{T,S}, Hermitian{Complex{T},S}) +typealias HermOrSym{T,S} Union{Hermitian{T,S}, Symmetric{T,S}} +typealias RealHermSymComplexHerm{T<:Real,S} Union{Hermitian{T,S}, Symmetric{T,S}, Hermitian{Complex{T},S}} size(A::HermOrSym, args...) = size(A.data, args...) getindex(A::Symmetric, i::Integer, j::Integer) = (A.uplo == 'U') == (i < j) ? getindex(A.data, i, j) : getindex(A.data, j, i) @@ -102,7 +102,7 @@ end eigvals!{T<:BlasReal,S<:StridedMatrix}(A::HermOrSym{T,S}, B::HermOrSym{T,S}) = LAPACK.sygvd!(1, 'N', A.uplo, A.data, B.uplo == A.uplo ? B.data : B.data')[1] eigvals!{T<:BlasComplex,S<:StridedMatrix}(A::Hermitian{T,S}, B::Hermitian{T,S}) = LAPACK.sygvd!(1, 'N', A.uplo, A.data, B.uplo == A.uplo ? B.data : B.data')[1] -function svdvals!{T<:Real,S}(A::Union(Hermitian{T,S}, Symmetric{T,S}, Hermitian{Complex{T},S})) # the union is the same as RealHermSymComplexHerm, but right now parametric typealiases are broken +function svdvals!{T<:Real,S}(A::Union{Hermitian{T,S}, Symmetric{T,S}, Hermitian{Complex{T},S}}) # the union is the same as RealHermSymComplexHerm, but right now parametric typealiases are broken vals = eigvals!(A) for i = 1:length(vals) vals[i] = abs(vals[i]) diff --git a/base/linalg/triangular.jl b/base/linalg/triangular.jl index d6dee55628f6b..82114bb9c6804 100644 --- a/base/linalg/triangular.jl +++ b/base/linalg/triangular.jl @@ -251,7 +251,7 @@ end inv{T}(A::UnitUpperTriangular{T}) = UnitUpperTriangular(A_ldiv_B!(A, eye(T, size(A, 1)))) inv{T}(A::UnitLowerTriangular{T}) = UnitLowerTriangular(A_ldiv_B!(A, eye(T, size(A, 1)))) -errorbounds{T<:Union(BigFloat, Complex{BigFloat}),S<:StridedMatrix}(A::AbstractTriangular{T,S}, X::StridedVecOrMat{T}, B::StridedVecOrMat{T}) = error("not implemented yet! Please submit a pull request.") +errorbounds{T<:Union{BigFloat, Complex{BigFloat}},S<:StridedMatrix}(A::AbstractTriangular{T,S}, X::StridedVecOrMat{T}, B::StridedVecOrMat{T}) = error("not implemented yet! Please submit a pull request.") function errorbounds{TA<:Number,S<:StridedMatrix,TX<:Number,TB<:Number}(A::AbstractTriangular{TA,S}, X::StridedVecOrMat{TX}, B::StridedVecOrMat{TB}) TAXB = promote_type(TA, TB, TX, Float32) errorbounds(convert(AbstractMatrix{TAXB}, A), convert(AbstractArray{TAXB}, X), convert(AbstractArray{TAXB}, B)) diff --git a/base/linalg/uniformscaling.jl b/base/linalg/uniformscaling.jl index 8084ca3ced7b3..5be4e5c3c479f 100644 --- a/base/linalg/uniformscaling.jl +++ b/base/linalg/uniformscaling.jl @@ -84,7 +84,7 @@ inv(J::UniformScaling) = UniformScaling(inv(J.λ)) /(J::UniformScaling, x::Number) = UniformScaling(J.λ/x) \(J1::UniformScaling, J2::UniformScaling) = J1.λ == 0 ? throw(SingularException(1)) : UniformScaling(J1.λ\J2.λ) -\{T<:Number}(A::Union(Bidiagonal{T},AbstractTriangular{T}), J::UniformScaling) = inv(A)*J.λ +\{T<:Number}(A::Union{Bidiagonal{T},AbstractTriangular{T}}, J::UniformScaling) = inv(A)*J.λ \(J::UniformScaling, A::AbstractVecOrMat) = J.λ == 0 ? throw(SingularException(1)) : J.λ\A \(A::AbstractMatrix, J::UniformScaling) = inv(A)*J.λ diff --git a/base/loading.jl b/base/loading.jl index 1ba13bc7374fa..b6eb34c9e05e3 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -104,7 +104,7 @@ include_string(txt::AbstractString, fname::AbstractString) = include_string(byte include_string(txt::AbstractString) = include_string(txt, "string") -function source_path(default::Union(AbstractString,Void)="") +function source_path(default::Union{AbstractString,Void}="") t = current_task() while true s = t.storage diff --git a/base/markdown/render/html.jl b/base/markdown/render/html.jl index ac74fcc04155f..9fd5df1fb599b 100644 --- a/base/markdown/render/html.jl +++ b/base/markdown/render/html.jl @@ -39,12 +39,12 @@ end function htmlesc(io::IO, s::Symbol) htmlesc(io, string(s)) end -function htmlesc(io::IO, xs::Union(String, Symbol)...) +function htmlesc(io::IO, xs::Union{String, Symbol}...) for s in xs htmlesc(io, s) end end -function htmlesc(s::Union(String, Symbol)) +function htmlesc(s::Union{String, Symbol}) sprint(htmlesc, s) end @@ -120,7 +120,7 @@ function htmlinline(io::IO, code::Code) end end -function htmlinline(io::IO, md::Union(Symbol, String)) +function htmlinline(io::IO, md::Union{Symbol, String}) htmlesc(io, md) end diff --git a/base/mmap.jl b/base/mmap.jl index 30705b650732d..3c65fd66ec75b 100644 --- a/base/mmap.jl +++ b/base/mmap.jl @@ -92,7 +92,7 @@ end @windows_only begin # Mmapped-array constructor -function mmap_array{T,N}(::Type{T}, dims::NTuple{N,Integer}, s::Union(IO,SharedMemSpec), offset::FileOffset) +function mmap_array{T,N}(::Type{T}, dims::NTuple{N,Integer}, s::Union{IO,SharedMemSpec}, offset::FileOffset) if isa(s,IO) hdl = _get_osfhandle(RawFD(fd(s))).handle if Int(hdl) == -1 diff --git a/base/mpfr.jl b/base/mpfr.jl index df29917148e6c..5d6aaf88ce6b7 100644 --- a/base/mpfr.jl +++ b/base/mpfr.jl @@ -82,10 +82,10 @@ end BigFloat(x::Integer) = BigFloat(BigInt(x)) -BigFloat(x::Union(Bool,Int8,Int16,Int32)) = BigFloat(convert(Clong,x)) -BigFloat(x::Union(UInt8,UInt16,UInt32)) = BigFloat(convert(Culong,x)) +BigFloat(x::Union{Bool,Int8,Int16,Int32}) = BigFloat(convert(Clong,x)) +BigFloat(x::Union{UInt8,UInt16,UInt32}) = BigFloat(convert(Culong,x)) -BigFloat(x::Union(Float16,Float32)) = BigFloat(Float64(x)) +BigFloat(x::Union{Float16,Float32}) = BigFloat(Float64(x)) BigFloat(x::Rational) = BigFloat(num(x)) / BigFloat(den(x)) function tryparse(::Type{BigFloat}, s::AbstractString, base::Int=0) @@ -129,20 +129,20 @@ unsafe_cast{T<:Integer}(::Type{T}, x::BigFloat, r::RoundingMode) = unsafe_cast(T unsafe_trunc{T<:Integer}(::Type{T}, x::BigFloat) = unsafe_cast(T,x,RoundToZero) -function trunc{T<:Union(Signed,Unsigned)}(::Type{T}, x::BigFloat) +function trunc{T<:Union{Signed,Unsigned}}(::Type{T}, x::BigFloat) (typemin(T) <= x <= typemax(T)) || throw(InexactError()) unsafe_cast(T,x,RoundToZero) end -function floor{T<:Union(Signed,Unsigned)}(::Type{T}, x::BigFloat) +function floor{T<:Union{Signed,Unsigned}}(::Type{T}, x::BigFloat) (typemin(T) <= x <= typemax(T)) || throw(InexactError()) unsafe_cast(T,x,RoundDown) end -function ceil{T<:Union(Signed,Unsigned)}(::Type{T}, x::BigFloat) +function ceil{T<:Union{Signed,Unsigned}}(::Type{T}, x::BigFloat) (typemin(T) <= x <= typemax(T)) || throw(InexactError()) unsafe_cast(T,x,RoundUp) end -function round{T<:Union(Signed,Unsigned)}(::Type{T}, x::BigFloat) +function round{T<:Union{Signed,Unsigned}}(::Type{T}, x::BigFloat) (typemin(T) <= x <= typemax(T)) || throw(InexactError()) unsafe_cast(T,x,ROUNDING_MODE[end]) end diff --git a/base/multi.jl b/base/multi.jl index 5a49a21dd74da..e297bc0ab0a2a 100644 --- a/base/multi.jl +++ b/base/multi.jl @@ -46,7 +46,7 @@ type WorkerConfig port::Nullable{Integer} # Used when launching additional workers at a host - count::Nullable{Union(Int, Symbol)} + count::Nullable{Union{Int, Symbol}} exename::Nullable{AbstractString} exeflags::Nullable{Cmd} @@ -194,7 +194,7 @@ end const LPROC = LocalProcess() -const map_pid_wrkr = Dict{Int, Union(Worker, LocalProcess)}() +const map_pid_wrkr = Dict{Int, Union{Worker, LocalProcess}}() const map_sock_wrkr = ObjectIdDict() const map_del_wrkr = Set{Int}() diff --git a/base/multidimensional.jl b/base/multidimensional.jl index 5b5e9ff9a6402..4bf52f2bd95e0 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -201,11 +201,11 @@ index_shape_dim(A, dim, ::Colon) = (trailingsize(A, dim),) # ambiguities for AbstractArray subtypes. See the note in abstractarray.jl # Note that it's most efficient to call checkbounds first, and then to_index -@inline function _getindex(l::LinearIndexing, A::AbstractArray, I::Union(Real, AbstractArray, Colon)...) +@inline function _getindex(l::LinearIndexing, A::AbstractArray, I::Union{Real, AbstractArray, Colon}...) checkbounds(A, I...) _unsafe_getindex(l, A, I...) end -@generated function _unsafe_getindex(l::LinearIndexing, A::AbstractArray, I::Union(Real, AbstractArray, Colon)...) +@generated function _unsafe_getindex(l::LinearIndexing, A::AbstractArray, I::Union{Real, AbstractArray, Colon}...) N = length(I) quote # This is specifically *not* inlined. @@ -250,7 +250,7 @@ end end # Fast source - compute the linear index -@generated function _unsafe_getindex!(dest::AbstractArray, ::LinearFast, src::AbstractArray, I::Union(Real, AbstractVector, Colon)...) +@generated function _unsafe_getindex!(dest::AbstractArray, ::LinearFast, src::AbstractArray, I::Union{Real, AbstractVector, Colon}...) N = length(I) quote $(Expr(:meta, :inline)) @@ -268,7 +268,7 @@ end end # Slow source - index with the indices provided. # TODO: this may not be the full dimensionality; that case could be optimized -@generated function _unsafe_getindex!(dest::AbstractArray, ::LinearSlow, src::AbstractArray, I::Union(Real, AbstractVector, Colon)...) +@generated function _unsafe_getindex!(dest::AbstractArray, ::LinearSlow, src::AbstractArray, I::Union{Real, AbstractVector, Colon}...) N = length(I) quote $(Expr(:meta, :inline)) @@ -307,11 +307,11 @@ _checksize(A::AbstractArray, dim, ::Real) = size(A, dim) == 1 # before redispatching to the _unsafe_batchsetindex! _iterable(v::AbstractArray) = v _iterable(v) = repeated(v) -@inline function _setindex!(l::LinearIndexing, A::AbstractArray, x, J::Union(Real,AbstractArray,Colon)...) +@inline function _setindex!(l::LinearIndexing, A::AbstractArray, x, J::Union{Real,AbstractArray,Colon}...) checkbounds(A, J...) _unsafe_setindex!(l, A, x, J...) end -@inline function _unsafe_setindex!(l::LinearIndexing, A::AbstractArray, x, J::Union(Real,AbstractVector,Colon)...) +@inline function _unsafe_setindex!(l::LinearIndexing, A::AbstractArray, x, J::Union{Real,AbstractVector,Colon}...) _unsafe_batchsetindex!(l, A, _iterable(x), to_index(J)...) end @@ -338,7 +338,7 @@ function _unsafe_setindex!(::LinearIndexing, A::AbstractArray, x, I::AbstractVec end # Use iteration over X so we don't need to worry about its storage -@generated function _unsafe_batchsetindex!(::LinearFast, A::AbstractArray, X, I::Union(Real,AbstractVector,Colon)...) +@generated function _unsafe_batchsetindex!(::LinearFast, A::AbstractArray, X, I::Union{Real,AbstractVector,Colon}...) N = length(I) quote @nexprs $N d->(I_d = I[d]) @@ -355,7 +355,7 @@ end A end end -@generated function _unsafe_batchsetindex!(::LinearSlow, A::AbstractArray, X, I::Union(Real,AbstractVector,Colon)...) +@generated function _unsafe_batchsetindex!(::LinearSlow, A::AbstractArray, X, I::Union{Real,AbstractVector,Colon}...) N = length(I) quote @nexprs $N d->(I_d = I[d]) @@ -387,16 +387,16 @@ function cartindex_exprs(indexes, syms) end exprs end -@generated function _getindex{T,N}(l::LinearIndexing, A::AbstractArray{T,N}, I::Union(Real,AbstractArray,Colon,CartesianIndex)...) +@generated function _getindex{T,N}(l::LinearIndexing, A::AbstractArray{T,N}, I::Union{Real,AbstractArray,Colon,CartesianIndex}...) :($(Expr(:meta, :inline)); getindex(A, $(cartindex_exprs(I, :I)...))) end -@generated function _unsafe_getindex{T,N}(l::LinearIndexing, A::AbstractArray{T,N}, I::Union(Real,AbstractArray,Colon,CartesianIndex)...) +@generated function _unsafe_getindex{T,N}(l::LinearIndexing, A::AbstractArray{T,N}, I::Union{Real,AbstractArray,Colon,CartesianIndex}...) :($(Expr(:meta, :inline)); unsafe_getindex(A, $(cartindex_exprs(I, :I)...))) end -@generated function _setindex!{T,N}(l::LinearIndexing, A::AbstractArray{T,N}, v, I::Union(Real,AbstractArray,Colon,CartesianIndex)...) +@generated function _setindex!{T,N}(l::LinearIndexing, A::AbstractArray{T,N}, v, I::Union{Real,AbstractArray,Colon,CartesianIndex}...) :($(Expr(:meta, :inline)); setindex!(A, v, $(cartindex_exprs(I, :I)...))) end -@generated function _unsafe_setindex!{T,N}(l::LinearIndexing, A::AbstractArray{T,N}, v, I::Union(Real,AbstractArray,Colon,CartesianIndex)...) +@generated function _unsafe_setindex!{T,N}(l::LinearIndexing, A::AbstractArray{T,N}, v, I::Union{Real,AbstractArray,Colon,CartesianIndex}...) :($(Expr(:meta, :inline)); unsafe_setindex!(A, v, $(cartindex_exprs(I, :I)...))) end @@ -440,7 +440,7 @@ end # then test whether the corresponding linear index is in linindex. # One exception occurs when only a small subset of the total # is desired, in which case we fall back to the div-based algorithm. -#@generated function merge_indexes{T<:Integer}(V, parentindexes::NTuple, parentdims::Dims, linindex::Union(Colon,Range{T}), lindim) +#@generated function merge_indexes{T<:Integer}(V, parentindexes::NTuple, parentdims::Dims, linindex::Union{Colon,Range{T}}, lindim) @generated function merge_indexes_in{TT}(V, parentindexes::TT, parentdims::Dims, linindex, lindim) N = length(parentindexes.parameters) # number of parent axes we're merging N > 0 || throw(ArgumentError("cannot merge empty indexes")) @@ -615,13 +615,13 @@ end # contiguous multidimensional indexing: if the first dimension is a range, # we can get some performance from using copy_chunks! -@inline function _unsafe_getindex!(X::BitArray, ::LinearFast, B::BitArray, I0::Union(UnitRange{Int}, Colon)) +@inline function _unsafe_getindex!(X::BitArray, ::LinearFast, B::BitArray, I0::Union{UnitRange{Int}, Colon}) copy_chunks!(X.chunks, 1, B.chunks, first(I0), index_lengths(B, I0)[1]) return X end # Optimization where the inner dimension is contiguous improves perf dramatically -@generated function _unsafe_getindex!(X::BitArray, ::LinearFast, B::BitArray, I0::Union(Colon,UnitRange{Int}), I::Union(Int,UnitRange{Int},Colon)...) +@generated function _unsafe_getindex!(X::BitArray, ::LinearFast, B::BitArray, I0::Union{Colon,UnitRange{Int}}, I::Union{Int,UnitRange{Int},Colon}...) N = length(I) quote $(Expr(:meta, :inline)) @@ -657,7 +657,7 @@ end # in the general multidimensional non-scalar case, can we do about 10% better # in most cases by manually hoisting the bitarray chunks access out of the loop # (This should really be handled by the compiler or with an immutable BitArray) -@generated function _unsafe_getindex!(X::BitArray, ::LinearFast, B::BitArray, I::Union(Int,AbstractVector{Int},Colon)...) +@generated function _unsafe_getindex!(X::BitArray, ::LinearFast, B::BitArray, I::Union{Int,AbstractVector{Int},Colon}...) N = length(I) quote $(Expr(:meta, :inline)) @@ -695,7 +695,7 @@ function unsafe_setindex!(B::BitArray, x::Bool, I0::UnitRange{Int}) return B end -@generated function unsafe_setindex!(B::BitArray, X::BitArray, I0::UnitRange{Int}, I::Union(Int,UnitRange{Int})...) +@generated function unsafe_setindex!(B::BitArray, X::BitArray, I0::UnitRange{Int}, I::Union{Int,UnitRange{Int}}...) N = length(I) quote length(X) == 0 && return B @@ -726,7 +726,7 @@ end end end -@generated function unsafe_setindex!(B::BitArray, x::Bool, I0::UnitRange{Int}, I::Union(Int,UnitRange{Int})...) +@generated function unsafe_setindex!(B::BitArray, x::Bool, I0::UnitRange{Int}, I::Union{Int,UnitRange{Int}}...) N = length(I) quote f0 = first(I0) diff --git a/base/multimedia.jl b/base/multimedia.jl index 2750135630637..be8c6f372c697 100644 --- a/base/multimedia.jl +++ b/base/multimedia.jl @@ -200,7 +200,7 @@ function redisplay(x) throw(MethodError(redisplay, (x,))) end -function redisplay(m::Union(MIME,AbstractString), x) +function redisplay(m::Union{MIME,AbstractString}, x) for i = length(displays):-1:1 xdisplayable(displays[i], m, x) && @try_display return redisplay(displays[i], m, x) @@ -210,7 +210,7 @@ end # default redisplay is simply to call display redisplay(d::Display, x) = display(d, x) -redisplay(d::Display, m::Union(MIME,AbstractString), x) = display(d, m, x) +redisplay(d::Display, m::Union{MIME,AbstractString}, x) = display(d, m, x) ########################################################################### diff --git a/base/nofloat_hashing.jl b/base/nofloat_hashing.jl index 17552943b5125..675c27560a30d 100644 --- a/base/nofloat_hashing.jl +++ b/base/nofloat_hashing.jl @@ -7,4 +7,4 @@ hx(a::UInt64, b::UInt64, h::UInt) = hash_uint64(3a + b - h) hash(x::UInt64, h::UInt) = hx(x, x, h) hash(x::Int64, h::UInt) = hx(reinterpret(UInt64,abs(x)), reinterpret(UInt64,x), h) -hash(x::Union(Bool,Char,Int8,UInt8,Int16,UInt16,Int32,UInt32), h::UInt) = hash(Int64(x), h) +hash(x::Union{Bool,Char,Int8,UInt8,Int16,UInt16,Int32,UInt32}, h::UInt) = hash(Int64(x), h) diff --git a/base/nullable.jl b/base/nullable.jl index 2bfbe2c0201cd..3e335da3970fd 100644 --- a/base/nullable.jl +++ b/base/nullable.jl @@ -4,7 +4,7 @@ immutable NullException <: Exception end Nullable{T}(value::T, isnull::Bool=false) = Nullable{T}(value, isnull) -Nullable() = Nullable{Union()}() +Nullable() = Nullable{Union{}}() eltype{T}(::Type{Nullable{T}}) = T @@ -15,7 +15,7 @@ end convert{T}(::Type{Nullable{T}}, x::T) = Nullable{T}(x) convert{T}(::Type{Nullable{T}}, ::Void) = Nullable{T}() -convert( ::Type{Nullable }, ::Void) = Nullable{Union()}() +convert( ::Type{Nullable }, ::Void) = Nullable{Union{}}() function show{T}(io::IO, x::Nullable{T}) if x.isnull diff --git a/base/operators.jl b/base/operators.jl index 493af62589de0..a99f2df8d81ac 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -173,8 +173,8 @@ eltype(t::DataType) = eltype(super(t)) eltype(x) = eltype(typeof(x)) # copying immutable things -copy(x::Union(Symbol,Number,AbstractString,Function,Tuple,LambdaStaticData, - TopNode,QuoteNode,DataType,Union)) = x +copy(x::Union{Symbol,Number,AbstractString,Function,Tuple,LambdaStaticData, + TopNode,QuoteNode,DataType,Union}) = x # function pipelining |>(x, f::Callable) = f(x) diff --git a/base/ordering.jl b/base/ordering.jl index a63a7047cc119..95d4f18cce27b 100644 --- a/base/ordering.jl +++ b/base/ordering.jl @@ -21,7 +21,7 @@ end ReverseOrdering(rev::ReverseOrdering) = rev.fwd ReverseOrdering{Fwd}(fwd::Fwd) = ReverseOrdering{Fwd}(fwd) -typealias DirectOrdering Union(ForwardOrdering,ReverseOrdering{ForwardOrdering}) +typealias DirectOrdering Union{ForwardOrdering,ReverseOrdering{ForwardOrdering}} const Forward = ForwardOrdering() const Reverse = ReverseOrdering(Forward) diff --git a/base/pkg.jl b/base/pkg.jl index de95efe3b1681..b7b48ad40e892 100644 --- a/base/pkg.jl +++ b/base/pkg.jl @@ -63,7 +63,7 @@ publish() = cd(Entry.publish,Dir.getmetabranch()) build() = cd(Entry.build) build(pkgs::AbstractString...) = cd(Entry.build,[pkgs...]) -generate(pkg::AbstractString, license::AbstractString; force::Bool=false, authors::Union(AbstractString,Array) = [], config::Dict=Dict()) = +generate(pkg::AbstractString, license::AbstractString; force::Bool=false, authors::Union{AbstractString,Array} = [], config::Dict=Dict()) = cd(Generate.package,pkg,license,force=force,authors=authors,config=config) diff --git a/base/pkg/entry.jl b/base/pkg/entry.jl index 0bc51cf602e03..5b57a98f68001 100644 --- a/base/pkg/entry.jl +++ b/base/pkg/entry.jl @@ -548,7 +548,7 @@ end nextbump(v::VersionNumber) = isrewritable(v) ? v : nextpatch(v) -function tag(pkg::AbstractString, ver::Union(Symbol,VersionNumber), force::Bool=false, commit::AbstractString="HEAD") +function tag(pkg::AbstractString, ver::Union{Symbol,VersionNumber}, force::Bool=false, commit::AbstractString="HEAD") ispath(pkg,".git") || error("$pkg is not a git repo") Git.dirty(dir=pkg) && error("$pkg is dirty – commit or stash changes to tag") diff --git a/base/pkg/generate.jl b/base/pkg/generate.jl index 70b1b90bc3c16..c9a3c3305ddf8 100644 --- a/base/pkg/generate.jl +++ b/base/pkg/generate.jl @@ -33,8 +33,8 @@ function package( pkg::AbstractString, license::AbstractString; force::Bool = false, - authors::Union(AbstractString,Array) = "", - years::Union(Int,AbstractString) = copyright_year(), + authors::Union{AbstractString,Array} = "", + years::Union{Int,AbstractString} = copyright_year(), user::AbstractString = github_user(), config::Dict = Dict(), ) @@ -103,8 +103,8 @@ function init(pkg::AbstractString, url::AbstractString=""; config::Dict=Dict()) end function license(pkg::AbstractString, license::AbstractString, - years::Union(Int,AbstractString), - authors::Union(AbstractString,Array); + years::Union{Int,AbstractString}, + authors::Union{AbstractString,Array}; force::Bool=false) genfile(pkg,"LICENSE.md",force) do io if !haskey(LICENSES,license) @@ -199,7 +199,7 @@ function copyright(years::AbstractString, authors::Array) return text end -mit(pkg::AbstractString, years::AbstractString, authors::Union(AbstractString,Array)) = +mit(pkg::AbstractString, years::AbstractString, authors::Union{AbstractString,Array}) = """ The $pkg.jl package is licensed under the MIT "Expat" License: @@ -225,7 +225,7 @@ $(copyright(years,authors)) > SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -bsd(pkg::AbstractString, years::AbstractString, authors::Union(AbstractString,Array)) = +bsd(pkg::AbstractString, years::AbstractString, authors::Union{AbstractString,Array}) = """ The $pkg.jl package is licensed under the Simplified "2-clause" BSD License: @@ -254,7 +254,7 @@ $(copyright(years,authors)) > OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ -asl(pkg::AbstractString, years::AbstractString, authors::Union(AbstractString,Array)) = +asl(pkg::AbstractString, years::AbstractString, authors::Union{AbstractString,Array}) = """ The $pkg.jl package is licensed under version 2.0 of the Apache License: diff --git a/base/pkg/query.jl b/base/pkg/query.jl index b3e8d271277c2..6c304c12aa644 100644 --- a/base/pkg/query.jl +++ b/base/pkg/query.jl @@ -66,7 +66,7 @@ function dependencies(avail::Dict, fix::Dict = Dict{ByteString,Fixed}("julia"=>F avail, conflicts end -typealias PackageState Union(Void,VersionNumber) +typealias PackageState Union{Void,VersionNumber} function diff(have::Dict, want::Dict, avail::Dict, fixed::Dict) change = Array(Tuple{ByteString,Tuple{PackageState,PackageState}},0) diff --git a/base/pkg/reqs.jl b/base/pkg/reqs.jl index 6b5e8b4eb9162..96dcae663d1f5 100644 --- a/base/pkg/reqs.jl +++ b/base/pkg/reqs.jl @@ -52,7 +52,7 @@ end # general machinery for parsing REQUIRE files -function read(readable::Union(IO,Base.AbstractCmd)) +function read(readable::Union{IO,Base.AbstractCmd}) lines = Line[] for line in eachline(readable) line = chomp(line) @@ -72,7 +72,7 @@ function write(io::IO, reqs::Requires) println(io, Requirement(pkg, reqs[pkg]).content) end end -write(file::AbstractString, r::Union(Vector{Line},Requires)) = open(io->write(io,r), file, "w") +write(file::AbstractString, r::Union{Vector{Line},Requires}) = open(io->write(io,r), file, "w") function parse(lines::Vector{Line}) reqs = Requires() diff --git a/base/pkg/resolve/versionweight.jl b/base/pkg/resolve/versionweight.jl index 7d0a128b12d86..92f7f996e2ed5 100644 --- a/base/pkg/resolve/versionweight.jl +++ b/base/pkg/resolve/versionweight.jl @@ -101,7 +101,7 @@ end const _vwprebuild_zero = VWPreBuild(0, HierarchicalValue(VWPreBuildItem)) -function VWPreBuild(ispre::Bool, desc::Tuple{Vararg{Union(Int,ASCIIString)}}) +function VWPreBuild(ispre::Bool, desc::Tuple{Vararg{Union{Int,ASCIIString}}}) isempty(desc) && return _vwprebuild_zero desc == ("",) && return VWPreBuild(ispre ? -1 : 1, HierarchicalValue(VWPreBuildItem[])) nonempty = ispre ? -1 : 0 diff --git a/base/pointer.jl b/base/pointer.jl index 6e10a8323e29d..a026b8f09a30a 100644 --- a/base/pointer.jl +++ b/base/pointer.jl @@ -5,7 +5,7 @@ const C_NULL = box(Ptr{Void}, 0) # pointer to integer -convert{T<:Union(Int,UInt)}(::Type{T}, x::Ptr) = box(T, unbox(Ptr,x)) +convert{T<:Union{Int,UInt}}(::Type{T}, x::Ptr) = box(T, unbox(Ptr,x)) convert{T<:Integer}(::Type{T}, x::Ptr) = convert(T,convert(UInt, x)) # integer to pointer diff --git a/base/precompile.jl b/base/precompile.jl index 1ddb88b68a5e9..62c7153881870 100644 --- a/base/precompile.jl +++ b/base/precompile.jl @@ -341,7 +341,7 @@ precompile(Base.push!, (Array{AbstractString, 1}, ASCIIString)) precompile(Base.push!, (Array{AbstractString,1}, UTF8String)) precompile(Base.push!, (Array{Base.Multimedia.Display, 1}, Base.Multimedia.TextDisplay)) precompile(Base.push!, (Array{Char, 1}, Char)) -precompile(Base.push!, (Array{Union(ASCIIString, UTF8String), 1}, ASCIIString)) +precompile(Base.push!, (Array{Union{ASCIIString, UTF8String}, 1}, ASCIIString)) precompile(Base.pushdisplay, (Base.Multimedia.TextDisplay,)) precompile(Base.pwd, ()) precompile(Base.read, (Base.Terminals.TTYTerminal, Type{Char})) @@ -479,7 +479,7 @@ precompile(Base.setindex!, (Base.Dict{Any, Any}, Base.RemoteValue, Tuple{Int64, precompile(Base.LineEdit.refresh_multi_line, (Array{Any, 1}, Base.Terminals.TerminalBuffer, Base.Terminals.TTYTerminal, Base.IOBuffer, Base.LineEdit.InputAreaState, Base.LineEdit.PromptState)) precompile(Base.schedule, (Array{Any, 1}, Task, Void)) precompile(Base.LineEdit.match_input, (Function, Base.LineEdit.MIState, Base.Terminals.TTYTerminal, Array{Char, 1}, Base.Dict{Char, Any})) -precompile(Base.convert, (Type{Union(ASCIIString, UTF8String)}, ASCIIString)) +precompile(Base.convert, (Type{Union{ASCIIString, UTF8String}}, ASCIIString)) precompile(Base.LineEdit.keymap_fcn, (Function, Base.LineEdit.MIState, ASCIIString)) precompile(Base.weak_key_delete!, (Base.Dict{Any, Any}, Base.RemoteRef)) precompile(==, (Base.RemoteRef, WeakRef)) diff --git a/base/primes.jl b/base/primes.jl index 4123afa8f7931..62a2a024db8cb 100644 --- a/base/primes.jl +++ b/base/primes.jl @@ -30,7 +30,7 @@ primesmask(n::Int) = primesmask(falses(n)) primesmask(n::Integer) = n <= typemax(Int) ? primesmask(Int(n)) : throw(ArgumentError("requested number of primes must be ≤ $(typemax(Int)), got $n")) -primes(n::Union(Integer,AbstractVector{Bool})) = find(primesmask(n)) +primes(n::Union{Integer,AbstractVector{Bool}}) = find(primesmask(n)) const PRIMES = primes(2^16) @@ -60,9 +60,9 @@ end # http://primes.utm.edu/prove/merged.html # http://miller-rabin.appspot.com # -witnesses(n::Union(UInt8,Int8,UInt16,Int16)) = (2,3) -witnesses(n::Union(UInt32,Int32)) = n < 1373653 ? (2,3) : (2,7,61) -witnesses(n::Union(UInt64,Int64)) = +witnesses(n::Union{UInt8,Int8,UInt16,Int16}) = (2,3) +witnesses(n::Union{UInt32,Int32}) = n < 1373653 ? (2,3) : (2,7,61) +witnesses(n::Union{UInt64,Int64}) = n < 1373653 ? (2,3) : n < 4759123141 ? (2,7,61) : n < 2152302898747 ? (2,3,5,7,11) : diff --git a/base/printf.jl b/base/printf.jl index e27f8c8656a23..9c74e4f802b1f 100644 --- a/base/printf.jl +++ b/base/printf.jl @@ -5,8 +5,8 @@ using Base.Grisu export @printf, @sprintf ### printf formatter generation ### -const SmallFloatingPoint = Union(Float64,Float32,Float16) -const SmallNumber = Union(SmallFloatingPoint,Base.Signed64,Base.Unsigned64,UInt128,Int128) +const SmallFloatingPoint = Union{Float64,Float32,Float16} +const SmallNumber = Union{SmallFloatingPoint,Base.Signed64,Base.Unsigned64,UInt128,Int128} function gen(s::AbstractString) args = [] diff --git a/base/process.jl b/base/process.jl index c1dc0957f8447..16fb3f20da00c 100644 --- a/base/process.jl +++ b/base/process.jl @@ -6,7 +6,7 @@ type Cmd <: AbstractCmd exec::Vector{ByteString} ignorestatus::Bool detach::Bool - env::Union(Array{ByteString},Void) + env::Union{Array{ByteString},Void} dir::UTF8String Cmd(exec::Vector{ByteString}) = new(exec, false, false, nothing, "") end @@ -49,7 +49,7 @@ function show(io::IO, cmd::Cmd) (print_dir || print_env) && print(io, ")") end -function show(io::IO, cmds::Union(OrCmds,ErrOrCmds)) +function show(io::IO, cmds::Union{OrCmds,ErrOrCmds}) print(io, "pipe(") show(io, cmds.a) print(io, ", ") @@ -91,7 +91,7 @@ uvtype(::DevNullStream) = UV_STREAM uvhandle(x::RawFD) = convert(Ptr{Void}, x.fd % UInt) uvtype(x::RawFD) = UV_RAW_FD -typealias Redirectable Union(UVStream, FS.File, FileRedirect, DevNullStream, IOStream, RawFD) +typealias Redirectable Union{UVStream, FS.File, FileRedirect, DevNullStream, IOStream, RawFD} type CmdRedirect <: AbstractCmd cmd::AbstractCmd @@ -116,7 +116,7 @@ end ignorestatus(cmd::Cmd) = (cmd.ignorestatus=true; cmd) -ignorestatus(cmd::Union(OrCmds,AndCmds)) = (ignorestatus(cmd.a); ignorestatus(cmd.b); cmd) +ignorestatus(cmd::Union{OrCmds,AndCmds}) = (ignorestatus(cmd.a); ignorestatus(cmd.b); cmd) detach(cmd::Cmd) = (cmd.detach=true; cmd) # like bytestring(s), but throw an error if s contains NUL, since @@ -166,11 +166,11 @@ function pipe(cmd::AbstractCmd; stdin=nothing, stdout=nothing, stderr=nothing, a end pipe(cmd::AbstractCmd, dest) = pipe(cmd, stdout=dest) -pipe(src::Union(Redirectable,AbstractString), cmd::AbstractCmd) = pipe(cmd, stdin=src) +pipe(src::Union{Redirectable,AbstractString}, cmd::AbstractCmd) = pipe(cmd, stdin=src) pipe(a, b, c, d...) = pipe(pipe(a,b), c, d...) -typealias RawOrBoxedHandle Union(UVHandle,UVStream,Redirectable,IOStream) +typealias RawOrBoxedHandle Union{UVHandle,UVStream,Redirectable,IOStream} typealias StdIOSet NTuple{3,RawOrBoxedHandle} type Process @@ -208,7 +208,7 @@ type ProcessChain err::Redirectable ProcessChain(stdios::StdIOSet) = new(Process[], stdios[1], stdios[2], stdios[3]) end -typealias ProcessChainOrNot Union(Bool,ProcessChain) +typealias ProcessChainOrNot Union{Bool,ProcessChain} function _jl_spawn(cmd, argv, loop::Ptr{Void}, pp::Process, in, out, err) diff --git a/base/profile.jl b/base/profile.jl index d51bb131197f4..ed4b16ff1d457 100644 --- a/base/profile.jl +++ b/base/profile.jl @@ -23,7 +23,7 @@ end #### #### User-level functions #### -function init(; n::Union(Void,Integer) = nothing, delay::Union(Void,Float64) = nothing) +function init(; n::Union{Void,Integer} = nothing, delay::Union{Void,Float64} = nothing) n_cur = ccall(:jl_profile_maxlen_data, Csize_t, ()) delay_cur = ccall(:jl_profile_delay_nsec, UInt64, ())/10^9 if n == nothing && delay == nothing diff --git a/base/random.jl b/base/random.jl index 92492a5b867fa..93da02512ea91 100644 --- a/base/random.jl +++ b/base/random.jl @@ -35,8 +35,8 @@ type Close1Open2 <: FloatInterval end RandomDevice(unlimited::Bool=true) = new(open(unlimited ? "/dev/urandom" : "/dev/random")) end - rand {T<:Union(Bool, Base.IntTypes...)}(rd::RandomDevice, ::Type{T}) = read( rd.file, T) - rand!{T<:Union(Bool, Base.IntTypes...)}(rd::RandomDevice, A::Array{T}) = read!(rd.file, A) + rand {T<:Union{Bool, Base.IntTypes...}}(rd::RandomDevice, ::Type{T}) = read( rd.file, T) + rand!{T<:Union{Bool, Base.IntTypes...}}(rd::RandomDevice, A::Array{T}) = read!(rd.file, A) end @windows_only begin @@ -47,12 +47,12 @@ end RandomDevice() = new(Array(UInt128, 1)) end - function rand{T<:Union(Bool, Base.IntTypes...)}(rd::RandomDevice, ::Type{T}) + function rand{T<:Union{Bool, Base.IntTypes...}}(rd::RandomDevice, ::Type{T}) win32_SystemFunction036!(rd.buffer) @inbounds return rd.buffer[1] % T end - rand!{T<:Union(Bool, Base.IntTypes...)}(rd::RandomDevice, A::Array{T}) = (win32_SystemFunction036!(A); A) + rand!{T<:Union{Bool, Base.IntTypes...}}(rd::RandomDevice, A::Array{T}) = (win32_SystemFunction036!(A); A) end rand(rng::RandomDevice, ::Type{Close1Open2}) = @@ -175,7 +175,7 @@ function srand() dsfmt_gv_srand() end -function srand(seed::Union(Integer, Vector{UInt32})) +function srand(seed::Union{Integer, Vector{UInt32}}) srand(GLOBAL_RNG, seed) dsfmt_gv_srand() end @@ -211,17 +211,17 @@ rand(r::AbstractArray, dims::Integer...) = rand(GLOBAL_RNG, r, convert(Tuple{Var @inline rand(r::AbstractRNG) = rand(r, CloseOpen) # MersenneTwister & RandomDevice -@inline rand(r::Union(RandomDevice,MersenneTwister), ::Type{Float64}) = rand(r, CloseOpen) +@inline rand(r::Union{RandomDevice,MersenneTwister}, ::Type{Float64}) = rand(r, CloseOpen) rand_ui10_raw(r::MersenneTwister) = rand_ui52_raw(r) rand_ui23_raw(r::MersenneTwister) = rand_ui52_raw(r) rand_ui10_raw(r::AbstractRNG) = rand(r, UInt16) rand_ui23_raw(r::AbstractRNG) = rand(r, UInt32) -rand(r::Union(RandomDevice,MersenneTwister), ::Type{Float16}) = +rand(r::Union{RandomDevice,MersenneTwister}, ::Type{Float16}) = Float16(reinterpret(Float32, (rand_ui10_raw(r) % UInt32 << 13) & 0x007fe000 | 0x3f800000) - 1) -rand(r::Union(RandomDevice,MersenneTwister), ::Type{Float32}) = +rand(r::Union{RandomDevice,MersenneTwister}, ::Type{Float32}) = reinterpret(Float32, rand_ui23_raw(r) % UInt32 & 0x007fffff | 0x3f800000) - 1 @@ -231,7 +231,7 @@ rand(r::Union(RandomDevice,MersenneTwister), ::Type{Float32}) = # MersenneTwister -@inline rand{T<:Union(Bool, Int8, UInt8, Int16, UInt16, Int32, UInt32)}(r::MersenneTwister, ::Type{T}) = rand_ui52_raw(r) % T +@inline rand{T<:Union{Bool, Int8, UInt8, Int16, UInt16, Int32, UInt32}}(r::MersenneTwister, ::Type{T}) = rand_ui52_raw(r) % T function rand(r::MersenneTwister, ::Type{UInt64}) reserve(r, 2) @@ -338,7 +338,7 @@ end @inline mask128(u::UInt128, ::Type{Float16}) = (u & 0x03ff03ff03ff03ff03ff03ff03ff03ff) | 0x3c003c003c003c003c003c003c003c00 @inline mask128(u::UInt128, ::Type{Float32}) = (u & 0x007fffff007fffff007fffff007fffff) | 0x3f8000003f8000003f8000003f800000 -function rand!{T<:Union(Float16, Float32)}(r::MersenneTwister, A::Array{T}, ::Type{Close1Open2}) +function rand!{T<:Union{Float16, Float32}}(r::MersenneTwister, A::Array{T}, ::Type{Close1Open2}) n = length(A) n128 = n * sizeof(T) ÷ 16 rand!(r, pointer_to_array(convert(Ptr{Float64}, pointer(A)), 2*n128), 2*n128, Close1Open2) @@ -362,7 +362,7 @@ function rand!{T<:Union(Float16, Float32)}(r::MersenneTwister, A::Array{T}, ::Ty A end -function rand!{T<:Union(Float16, Float32)}(r::MersenneTwister, A::Array{T}, ::Type{CloseOpen}) +function rand!{T<:Union{Float16, Float32}}(r::MersenneTwister, A::Array{T}, ::Type{CloseOpen}) rand!(r, A, Close1Open2) I32 = one(Float32) for i in eachindex(A) @@ -371,7 +371,7 @@ function rand!{T<:Union(Float16, Float32)}(r::MersenneTwister, A::Array{T}, ::Ty A end -rand!{T<:Union(Float16, Float32)}(r::MersenneTwister, A::Array{T}) = rand!(r, A, CloseOpen) +rand!{T<:Union{Float16, Float32}}(r::MersenneTwister, A::Array{T}) = rand!(r, A, CloseOpen) function rand!(r::MersenneTwister, A::Array{UInt128}, n::Int=length(A)) @@ -402,7 +402,7 @@ function rand!(r::MersenneTwister, A::Array{UInt128}, n::Int=length(A)) A end -function rand!{T<:Union(Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128)}(r::MersenneTwister, A::Array{T}) +function rand!{T<:Union{Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128}}(r::MersenneTwister, A::Array{T}) n=length(A) n128 = n * sizeof(T) ÷ 16 rand!(r, pointer_to_array(convert(Ptr{UInt128}, pointer(A)), n128)) @@ -434,7 +434,7 @@ immutable RangeGeneratorInt{T<:Integer, U<:Unsigned} <: RangeGenerator u::U # rejection threshold end # generators with 32, 128 bits entropy -RangeGeneratorInt{T, U<:Union(UInt32, UInt128)}(a::T, k::U) = RangeGeneratorInt{T, U}(a, k, maxmultiple(k)) +RangeGeneratorInt{T, U<:Union{UInt32, UInt128}}(a::T, k::U) = RangeGeneratorInt{T, U}(a, k, maxmultiple(k)) # mixed 32/64 bits entropy generator RangeGeneratorInt{T}(a::T, k::UInt64) = RangeGeneratorInt{T,UInt64}(a, k, maxmultiplemix(k)) # generator for ranges @@ -492,7 +492,7 @@ end # this function uses 32 bit entropy for small ranges of length <= typemax(UInt32) + 1 # RangeGeneratorInt is responsible for providing the right value of k -function rand{T<:Union(UInt64, Int64)}(rng::AbstractRNG, g::RangeGeneratorInt{T,UInt64}) +function rand{T<:Union{UInt64, Int64}}(rng::AbstractRNG, g::RangeGeneratorInt{T,UInt64}) local x::UInt64 if (g.k - 1) >> 32 == 0 x = rand(rng, UInt32) @@ -548,7 +548,7 @@ else end end -rand{T<:Union(Signed,Unsigned,BigInt,Bool,Char)}(rng::AbstractRNG, r::UnitRange{T}) = rand(rng, RangeGenerator(r)) +rand{T<:Union{Signed,Unsigned,BigInt,Bool,Char}}(rng::AbstractRNG, r::UnitRange{T}) = rand(rng, RangeGenerator(r)) # Randomly draw a sample from an AbstractArray r @@ -562,7 +562,7 @@ function rand!(rng::AbstractRNG, A::AbstractArray, g::RangeGenerator) return A end -rand!{T<:Union(Signed,Unsigned,BigInt,Bool,Char)}(rng::AbstractRNG, A::AbstractArray, r::UnitRange{T}) = rand!(rng, A, RangeGenerator(r)) +rand!{T<:Union{Signed,Unsigned,BigInt,Bool,Char}}(rng::AbstractRNG, A::AbstractArray, r::UnitRange{T}) = rand!(rng, A, RangeGenerator(r)) function rand!(rng::AbstractRNG, A::AbstractArray, r::AbstractArray) g = RangeGenerator(1:(length(r))) diff --git a/base/range.jl b/base/range.jl index 7e58a677eb3d1..00cfdeef620a1 100644 --- a/base/range.jl +++ b/base/range.jl @@ -272,7 +272,7 @@ length(r::UnitRange) = Integer(r.stop - r.start + 1) length(r::FloatRange) = Integer(r.len) length(r::LinSpace) = Integer(r.len + signbit(r.len - 1)) -function length{T<:Union(Int,UInt,Int64,UInt64)}(r::StepRange{T}) +function length{T<:Union{Int,UInt,Int64,UInt64}}(r::StepRange{T}) isempty(r) && return zero(T) if r.step > 1 return checked_add(convert(T, div(unsigned(r.stop - r.start), r.step)), one(T)) @@ -283,13 +283,13 @@ function length{T<:Union(Int,UInt,Int64,UInt64)}(r::StepRange{T}) end end -length{T<:Union(Int,UInt,Int64,UInt64)}(r::UnitRange{T}) = +length{T<:Union{Int,UInt,Int64,UInt64}}(r::UnitRange{T}) = checked_add(checked_sub(r.stop, r.start), one(T)) # some special cases to favor default Int type let smallint = (Int === Int64 ? - Union(Int8,UInt8,Int16,UInt16,Int32,UInt32) : - Union(Int8,UInt8,Int16,UInt16)) + Union{Int8,UInt8,Int16,UInt16,Int32,UInt32} : + Union{Int8,UInt8,Int16,UInt16}) global length function length{T <: smallint}(r::StepRange{T}) diff --git a/base/reduce.jl b/base/reduce.jl index d681855f3cd7b..a4850339135ec 100644 --- a/base/reduce.jl +++ b/base/reduce.jl @@ -5,15 +5,15 @@ ###### Generic (map)reduce functions ###### if Int === Int32 -typealias SmallSigned Union(Int8,Int16) -typealias SmallUnsigned Union(UInt8,UInt16) +typealias SmallSigned Union{Int8,Int16} +typealias SmallUnsigned Union{UInt8,UInt16} else -typealias SmallSigned Union(Int8,Int16,Int32) -typealias SmallUnsigned Union(UInt8,UInt16,UInt32) +typealias SmallSigned Union{Int8,Int16,Int32} +typealias SmallUnsigned Union{UInt8,UInt16,UInt32} end -typealias CommonReduceResult Union(UInt64,UInt128,Int64,Int128,Float32,Float64) -typealias WidenReduceResult Union(SmallSigned, SmallUnsigned, Float16) +typealias CommonReduceResult Union{UInt64,UInt128,Int64,Int128,Float32,Float64} +typealias WidenReduceResult Union{SmallSigned, SmallUnsigned, Float16} # r_promote: promote x to the type of reduce(op, [x]) r_promote(op, x::WidenReduceResult) = widen(x) @@ -186,7 +186,7 @@ sum_pairwise_blocksize(::Abs2Fun) = 4096 mapreduce_impl(f, op::AddFun, A::AbstractArray, ifirst::Int, ilast::Int) = mapreduce_pairwise_impl(f, op, A, ifirst, ilast, sum_pairwise_blocksize(f)) -sum(f::Union(Callable,Func{1}), a) = mapreduce(f, AddFun(), a) +sum(f::Union{Callable,Func{1}}, a) = mapreduce(f, AddFun(), a) sum(a) = mapreduce(IdFun(), AddFun(), a) sum(a::AbstractArray{Bool}) = countnz(a) sumabs(a) = mapreduce(AbsFun(), AddFun(), a) @@ -217,7 +217,7 @@ end ## prod -prod(f::Union(Callable,Func{1}), a) = mapreduce(f, MulFun(), a) +prod(f::Union{Callable,Func{1}}, a) = mapreduce(f, MulFun(), a) prod(a) = mapreduce(IdFun(), MulFun(), a) prod(A::AbstractArray{Bool}) = @@ -261,8 +261,8 @@ function mapreduce_impl(f, op::MinFun, A::AbstractArray, first::Int, last::Int) v end -maximum(f::Union(Callable,Func{1}), a) = mapreduce(f, MaxFun(), a) -minimum(f::Union(Callable,Func{1}), a) = mapreduce(f, MinFun(), a) +maximum(f::Union{Callable,Func{1}}, a) = mapreduce(f, MaxFun(), a) +minimum(f::Union{Callable,Func{1}}, a) = mapreduce(f, MinFun(), a) maximum(a) = mapreduce(IdFun(), MaxFun(), a) minimum(a) = mapreduce(IdFun(), MinFun(), a) @@ -333,8 +333,8 @@ end all(a) = mapreduce(IdFun(), AndFun(), a) any(a) = mapreduce(IdFun(), OrFun(), a) -all(pred::Union(Callable,Func{1}), a) = mapreduce(pred, AndFun(), a) -any(pred::Union(Callable,Func{1}), a) = mapreduce(pred, OrFun(), a) +all(pred::Union{Callable,Func{1}}, a) = mapreduce(pred, AndFun(), a) +any(pred::Union{Callable,Func{1}}, a) = mapreduce(pred, OrFun(), a) ## in & contains @@ -362,7 +362,7 @@ end ## countnz & count -function count(pred::Union(Callable,Func{1}), itr) +function count(pred::Union{Callable,Func{1}}, itr) n = 0 for x in itr pred(x) && (n += 1) @@ -370,7 +370,7 @@ function count(pred::Union(Callable,Func{1}), itr) return n end -function count(pred::Union(Callable,Func{1}), a::AbstractArray) +function count(pred::Union{Callable,Func{1}}, a::AbstractArray) n = 0 for i = 1:length(a) @inbounds if pred(a[i]) diff --git a/base/reducedim.jl b/base/reducedim.jl index 886eeb69f94d3..55c2da81a446a 100644 --- a/base/reducedim.jl +++ b/base/reducedim.jl @@ -122,7 +122,7 @@ end reducedim_init{T}(f, op::MaxFun, A::AbstractArray{T}, region) = reducedim_initarray0(A, region, typemin(f(zero(T)))) reducedim_init{T}(f, op::MinFun, A::AbstractArray{T}, region) = reducedim_initarray0(A, region, typemax(f(zero(T)))) -reducedim_init{T}(f::Union(AbsFun,Abs2Fun), op::MaxFun, A::AbstractArray{T}, region) = +reducedim_init{T}(f::Union{AbsFun,Abs2Fun}, op::MaxFun, A::AbstractArray{T}, region) = reducedim_initarray(A, region, zero(f(zero(T)))) reducedim_init(f, op::AndFun, A::AbstractArray, region) = reducedim_initarray(A, region, true) @@ -131,19 +131,19 @@ reducedim_init(f, op::OrFun, A::AbstractArray, region) = reducedim_initarray(A, # specialize to make initialization more efficient for common cases for (IT, RT) in ((CommonReduceResult, :(eltype(A))), (SmallSigned, :Int), (SmallUnsigned, :UInt)) - T = Union([AbstractArray{t} for t in IT.types]..., [AbstractArray{Complex{t}} for t in IT.types]...) + T = Union{[AbstractArray{t} for t in IT.types]..., [AbstractArray{Complex{t}} for t in IT.types]...} @eval begin reducedim_init(f::IdFun, op::AddFun, A::$T, region) = reducedim_initarray(A, region, zero($RT)) reducedim_init(f::IdFun, op::MulFun, A::$T, region) = reducedim_initarray(A, region, one($RT)) - reducedim_init(f::Union(AbsFun,Abs2Fun), op::AddFun, A::$T, region) = + reducedim_init(f::Union{AbsFun,Abs2Fun}, op::AddFun, A::$T, region) = reducedim_initarray(A, region, real(zero($RT))) - reducedim_init(f::Union(AbsFun,Abs2Fun), op::MulFun, A::$T, region) = + reducedim_init(f::Union{AbsFun,Abs2Fun}, op::MulFun, A::$T, region) = reducedim_initarray(A, region, real(one($RT))) end end -reducedim_init(f::Union(IdFun,AbsFun,Abs2Fun), op::AddFun, A::AbstractArray{Bool}, region) = +reducedim_init(f::Union{IdFun,AbsFun,Abs2Fun}, op::AddFun, A::AbstractArray{Bool}, region) = reducedim_initarray(A, region, 0) @@ -252,11 +252,11 @@ for (fname, Op) in [(:sum, :AddFun), (:prod, :MulFun), fname! = symbol(fname, '!') @eval begin - $(fname!)(f::Union(Function,Func{1}), r::AbstractArray, A::AbstractArray; init::Bool=true) = + $(fname!)(f::Union{Function,Func{1}}, r::AbstractArray, A::AbstractArray; init::Bool=true) = mapreducedim!(f, $(Op)(), initarray!(r, $(Op)(), init), A) $(fname!)(r::AbstractArray, A::AbstractArray; init::Bool=true) = $(fname!)(IdFun(), r, A; init=init) - $(fname)(f::Union(Function,Func{1}), A::AbstractArray, region) = + $(fname)(f::Union{Function,Func{1}}, A::AbstractArray, region) = mapreducedim(f, $(Op)(), A, region) $(fname)(A::AbstractArray, region) = $(fname)(IdFun(), A, region) end diff --git a/base/regex.jl b/base/regex.jl index d6b229f922494..06cb1b59c64cc 100644 --- a/base/regex.jl +++ b/base/regex.jl @@ -89,7 +89,7 @@ end immutable RegexMatch match::SubString{UTF8String} - captures::Vector{Union(Void,SubString{UTF8String})} + captures::Vector{Union{Void,SubString{UTF8String}}} offset::Int offsets::Vector{Int} end @@ -133,13 +133,13 @@ function match(re::Regex, str::UTF8String, idx::Integer, add_opts::UInt32=UInt32 ovec = re.ovec n = div(length(ovec),2) - 1 mat = SubString(str, ovec[1]+1, ovec[2]) - cap = Union(Void,SubString{UTF8String})[ + cap = Union{Void,SubString{UTF8String}}[ ovec[2i+1] == PCRE.UNSET ? nothing : SubString(str, ovec[2i+1]+1, ovec[2i+2]) for i=1:n ] off = Int[ ovec[2i+1]+1 for i=1:n ] RegexMatch(mat, cap, ovec[1]+1, off) end -match(re::Regex, str::Union(ByteString,SubString), idx::Integer, add_opts::UInt32=UInt32(0)) = +match(re::Regex, str::Union{ByteString,SubString}, idx::Integer, add_opts::UInt32=UInt32(0)) = match(re, utf8(str), idx, add_opts) match(r::Regex, s::AbstractString) = match(r, s, start(s)) @@ -180,10 +180,10 @@ function matchall(re::Regex, str::UTF8String, overlap::Bool=false) matches end -matchall(re::Regex, str::Union(ByteString,SubString), overlap::Bool=false) = +matchall(re::Regex, str::Union{ByteString,SubString}, overlap::Bool=false) = matchall(re, utf8(str), overlap) -function search(str::Union(ByteString,SubString), re::Regex, idx::Integer) +function search(str::Union{ByteString,SubString}, re::Regex, idx::Integer) if idx > nextind(str,endof(str)) throw(BoundsError()) end diff --git a/base/replutil.jl b/base/replutil.jl index a2fdaf873b24d..f32e4104248aa 100644 --- a/base/replutil.jl +++ b/base/replutil.jl @@ -35,7 +35,7 @@ end writemime(io::IO, ::MIME"text/plain", t::Associative) = showdict(io, t, limit=true) -writemime(io::IO, ::MIME"text/plain", t::Union(KeyIterator, ValueIterator)) = +writemime(io::IO, ::MIME"text/plain", t::Union{KeyIterator, ValueIterator}) = showkv(io, t, limit=true) @@ -241,10 +241,10 @@ function show_method_candidates(io::IO, ex::MethodError) t_in = typeintersect(Tuple{sig[1:i]...}, Tuple{t_i[1:j]...}) # If the function is one of the special cased then it should break the loop if # the type of the first argument is not matched. - t_in === Union() && special && i == 1 && break + t_in === Union{} && special && i == 1 && break if use_constructor_syntax && i == 1 right_matches += i - elseif t_in === Union() + elseif t_in === Union{} if Base.have_color Base.with_output_color(:red, buf) do buf print(buf, "::$sigstr") diff --git a/base/rounding.jl b/base/rounding.jl index 3d206819f3061..2f676da8e537b 100644 --- a/base/rounding.jl +++ b/base/rounding.jl @@ -40,11 +40,11 @@ function from_fenv(r::Integer) end end -set_rounding_raw{T<:Union(Float32,Float64)}(::Type{T},i::Integer) = ccall(:fesetround, Cint, (Cint,), i) -get_rounding_raw{T<:Union(Float32,Float64)}(::Type{T}) = ccall(:fegetround, Cint, ()) +set_rounding_raw{T<:Union{Float32,Float64}}(::Type{T},i::Integer) = ccall(:fesetround, Cint, (Cint,), i) +get_rounding_raw{T<:Union{Float32,Float64}}(::Type{T}) = ccall(:fegetround, Cint, ()) -set_rounding{T<:Union(Float32,Float64)}(::Type{T},r::RoundingMode) = set_rounding_raw(T,to_fenv(r)) -get_rounding{T<:Union(Float32,Float64)}(::Type{T}) = from_fenv(get_rounding_raw(T)) +set_rounding{T<:Union{Float32,Float64}}(::Type{T},r::RoundingMode) = set_rounding_raw(T,to_fenv(r)) +get_rounding{T<:Union{Float32,Float64}}(::Type{T}) = from_fenv(get_rounding_raw(T)) function with_rounding{T}(f::Function, ::Type{T}, rounding::RoundingMode) old_rounding_raw = get_rounding_raw(T) diff --git a/base/sharedarray.jl b/base/sharedarray.jl index 8ef176423ef47..a73a3db243a63 100644 --- a/base/sharedarray.jl +++ b/base/sharedarray.jl @@ -214,7 +214,7 @@ getindex(S::SharedArray) = getindex(S.s) getindex(S::SharedArray, I::Real) = getindex(S.s, I) getindex(S::SharedArray, I::AbstractArray) = getindex(S.s, I) getindex(S::SharedArray, I::Colon) = getindex(S.s, I) -@generated function getindex(S::SharedArray, I::Union(Real,AbstractVector,Colon)...) +@generated function getindex(S::SharedArray, I::Union{Real,AbstractVector,Colon}...) N = length(I) Isplat = Expr[:(I[$d]) for d = 1:N] quote @@ -226,7 +226,7 @@ setindex!(S::SharedArray, x) = setindex!(S.s, x) setindex!(S::SharedArray, x, I::Real) = setindex!(S.s, x, I) setindex!(S::SharedArray, x, I::AbstractArray) = setindex!(S.s, x, I) setindex!(S::SharedArray, x, I::Colon) = setindex!(S.s, x, I) -@generated function setindex!(S::SharedArray, x, I::Union(Real,AbstractVector,Colon)...) +@generated function setindex!(S::SharedArray, x, I::Union{Real,AbstractVector,Colon}...) N = length(I) Isplat = Expr[:(I[$d]) for d = 1:N] quote @@ -266,15 +266,15 @@ end shmem_fill(v, I::Int...; kwargs...) = shmem_fill(v, I; kwargs...) # rand variant with range -function shmem_rand(TR::Union(DataType, UnitRange), dims; kwargs...) +function shmem_rand(TR::Union{DataType, UnitRange}, dims; kwargs...) if isa(TR, UnitRange) SharedArray(Int, dims; init = S -> map!((x)->rand(TR), S.loc_subarr_1d), kwargs...) else SharedArray(TR, dims; init = S -> map!((x)->rand(TR), S.loc_subarr_1d), kwargs...) end end -shmem_rand(TR::Union(DataType, UnitRange), i::Int; kwargs...) = shmem_rand(TR, (i,); kwargs...) -shmem_rand(TR::Union(DataType, UnitRange), I::Int...; kwargs...) = shmem_rand(TR, I; kwargs...) +shmem_rand(TR::Union{DataType, UnitRange}, i::Int; kwargs...) = shmem_rand(TR, (i,); kwargs...) +shmem_rand(TR::Union{DataType, UnitRange}, I::Int...; kwargs...) = shmem_rand(TR, I; kwargs...) shmem_rand(dims; kwargs...) = shmem_rand(Float64, dims; kwargs...) shmem_rand(I::Int...; kwargs...) = shmem_rand(I; kwargs...) diff --git a/base/show.jl b/base/show.jl index 8500192c03a65..418a83b202945 100644 --- a/base/show.jl +++ b/base/show.jl @@ -252,8 +252,8 @@ show(io::IO, s::Symbol) = show_unquoted_quote_expr(io, s, 0, 0) # eval(parse("Set{Int64}([2,3,1])”) # ==> An actual set # While this isn’t true of ALL show methods, it is of all ASTs. -typealias ExprNode Union(Expr, QuoteNode, SymbolNode, LineNumberNode, - LabelNode, GotoNode, TopNode) +typealias ExprNode Union{Expr, QuoteNode, SymbolNode, LineNumberNode, + LabelNode, GotoNode, TopNode} # Operators have precedence levels from 1-N, and show_unquoted defaults to a # precedence level of 0 (the fourth argument). The top-level print and show # methods use a precedence of -1 to specially allow space-separated macro syntax diff --git a/base/socket.jl b/base/socket.jl index 24cbe77ec98af..bda44d325b058 100644 --- a/base/socket.jl +++ b/base/socket.jl @@ -394,7 +394,7 @@ function UDPSocket() this end -function uvfinalize(uv::Union(TTY,Pipe,PipeServer,TCPServer,TCPSocket,UDPSocket)) +function uvfinalize(uv::Union{TTY,Pipe,PipeServer,TCPServer,TCPSocket,UDPSocket}) if (uv.status != StatusUninit && uv.status != StatusInit) close(uv) end @@ -417,7 +417,7 @@ const UV_UDP_IPV6ONLY = 1 # remainder was discarded by the OS. const UV_UDP_PARTIAL = 2 -function bind(sock::Union(TCPServer,UDPSocket), host::IPv4, port::Integer) +function bind(sock::Union{TCPServer,UDPSocket}, host::IPv4, port::Integer) if sock.status != StatusInit error("$(typeof(sock)) is not initialized") end @@ -498,7 +498,7 @@ function recvfrom(sock::UDPSocket) error("UDPSocket is not initialized and open") end _recv_start(sock) - stream_wait(sock,sock.recvnotify)::Tuple{Union(IPv4, IPv6), Vector{UInt8}} + stream_wait(sock,sock.recvnotify)::Tuple{Union{IPv4, IPv6}, Vector{UInt8}} end diff --git a/base/sort.jl b/base/sort.jl index d9386889fe262..73dfc767c77d3 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -115,12 +115,12 @@ function select!(v::AbstractVector, r::OrdinalRange, lo::Int, hi::Int, o::Orderi end end -select!(v::AbstractVector, k::Union(Int,OrdinalRange), o::Ordering) = select!(v,k,1,length(v),o) -select!(v::AbstractVector, k::Union(Int,OrdinalRange); +select!(v::AbstractVector, k::Union{Int,OrdinalRange}, o::Ordering) = select!(v,k,1,length(v),o) +select!(v::AbstractVector, k::Union{Int,OrdinalRange}; lt=isless, by=identity, rev::Bool=false, order::Ordering=Forward) = select!(v, k, ord(lt,by,rev,order)) -select(v::AbstractVector, k::Union(Int,OrdinalRange); kws...) = select!(copy(v), k; kws...) +select(v::AbstractVector, k::Union{Int,OrdinalRange}; kws...) = select!(copy(v), k; kws...) # reference on sorted binary search: # http://www.tbray.org/ongoing/When/200x/2003/03/22/Binary @@ -428,7 +428,7 @@ import Core.Intrinsics: unbox, slt_int import ..Sort: sort! import ...Order: lt, DirectOrdering -typealias Floats Union(Float32,Float64) +typealias Floats Union{Float32,Float64} immutable Left <: Ordering end immutable Right <: Ordering end diff --git a/base/sparse/cholmod.jl b/base/sparse/cholmod.jl index 8de729fc72be0..76b1dacd48b37 100644 --- a/base/sparse/cholmod.jl +++ b/base/sparse/cholmod.jl @@ -995,7 +995,7 @@ copy(A::Dense) = copy_dense(A) copy(A::Sparse) = copy_sparse(A) copy(A::Factor) = copy_factor(A) -function size(A::Union(Dense,Sparse)) +function size(A::Union{Dense,Sparse}) s = unsafe_load(A.p) return (Int(s.nrow), Int(s.ncol)) end diff --git a/base/sparse/cholmod_h.jl b/base/sparse/cholmod_h.jl index a7699e58276ec..5f51ec50463ea 100644 --- a/base/sparse/cholmod_h.jl +++ b/base/sparse/cholmod_h.jl @@ -60,15 +60,15 @@ const MM_HERMITIAN_POSDIAG = 7 if Int(ccall((:jl_cholmod_sizeof_long, :libsuitesparse_wrapper),Csize_t,())) == 4 const SuiteSparse_long = Int32 const IndexTypes = (:Int32, ) - typealias ITypes Union(Int32) + typealias ITypes Union{Int32} else const SuiteSparse_long = Int64 const IndexTypes = (:Int32, :Int64) - typealias ITypes Union(Int32, Int64) + typealias ITypes Union{Int32, Int64} end -typealias VTypes Union(Complex128, Float64) -typealias VRealTypes Union(Float64) +typealias VTypes Union{Complex128, Float64} +typealias VRealTypes Union{Float64} type CHOLMODException <: Exception msg::AbstractString diff --git a/base/sparse/csparse.jl b/base/sparse/csparse.jl index 433d2160841a6..2593a41e2ca3d 100644 --- a/base/sparse/csparse.jl +++ b/base/sparse/csparse.jl @@ -14,7 +14,7 @@ # http://www.cise.ufl.edu/research/sparse/CSparse/ function sparse{Tv,Ti<:Integer}(I::AbstractVector{Ti}, J::AbstractVector{Ti}, V::AbstractVector{Tv}, - nrow::Integer, ncol::Integer, combine::Union(Function,Base.Func)) + nrow::Integer, ncol::Integer, combine::Union{Function,Base.Func}) if length(I) == 0; return spzeros(eltype(V),nrow,ncol); end N = length(I) diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl index c61e5469e70ac..1595f84d0a5f9 100644 --- a/base/sparse/sparsematrix.jl +++ b/base/sparse/sparsematrix.jl @@ -219,7 +219,7 @@ sparsevec(I::AbstractVector, V, m::Integer) = sparsevec(I, V, m, AddFun()) sparsevec(I::AbstractVector, V) = sparsevec(I, V, maximum(I), AddFun()) -function sparsevec(I::AbstractVector, V, m::Integer, combine::Union(Function,Func)) +function sparsevec(I::AbstractVector, V, m::Integer, combine::Union{Function,Func}) nI = length(I) if isa(V, Number); V = fill(V, nI); end p = sortperm(I) @@ -252,7 +252,7 @@ sparse_IJ_sorted!(I,J,V::AbstractVector{Bool},m,n) = sparse_IJ_sorted!(I,J,V,m,n function sparse_IJ_sorted!{Ti<:Integer}(I::AbstractVector{Ti}, J::AbstractVector{Ti}, V::AbstractVector, - m::Integer, n::Integer, combine::Union(Function,Func)) + m::Integer, n::Integer, combine::Union{Function,Func}) m = m < 0 ? 0 : m n = n < 0 ? 0 : n @@ -310,7 +310,7 @@ sparse(I,J,V::AbstractVector,m,n) = sparse(I, J, V, Int(m), Int(n), AddFun()) sparse(I,J,V::AbstractVector{Bool},m,n) = sparse(I, J, V, Int(m), Int(n), OrFun()) -sparse(I,J,v::Number,m,n,combine::Union(Function,Func)) = sparse(I, J, fill(v,length(I)), Int(m), Int(n), combine) +sparse(I,J,v::Number,m,n,combine::Union{Function,Func}) = sparse(I, J, fill(v,length(I)), Int(m), Int(n), combine) function sparse(T::SymTridiagonal) m = length(T.dv) @@ -858,9 +858,9 @@ broadcast_zpreserving!(args...) = broadcast!(args...) broadcast_zpreserving(args...) = broadcast(args...) broadcast_zpreserving{Tv1,Ti1,Tv2,Ti2}(f::Function, A_1::SparseMatrixCSC{Tv1,Ti1}, A_2::SparseMatrixCSC{Tv2,Ti2}) = broadcast_zpreserving!(f, spzeros(promote_type(Tv1, Tv2), promote_type(Ti1, Ti2), broadcast_shape(A_1, A_2)...), A_1, A_2) -broadcast_zpreserving{Tv,Ti}(f::Function, A_1::SparseMatrixCSC{Tv,Ti}, A_2::Union(Array,BitArray,Number)) = +broadcast_zpreserving{Tv,Ti}(f::Function, A_1::SparseMatrixCSC{Tv,Ti}, A_2::Union{Array,BitArray,Number}) = broadcast_zpreserving!(f, spzeros(promote_eltype(A_1, A_2), Ti, broadcast_shape(A_1, A_2)...), A_1, A_2) -broadcast_zpreserving{Tv,Ti}(f::Function, A_1::Union(Array,BitArray,Number), A_2::SparseMatrixCSC{Tv,Ti}) = +broadcast_zpreserving{Tv,Ti}(f::Function, A_1::Union{Array,BitArray,Number}, A_2::SparseMatrixCSC{Tv,Ti}) = broadcast_zpreserving!(f, spzeros(promote_eltype(A_1, A_2), Ti, broadcast_shape(A_1, A_2)...), A_1, A_2) @@ -1763,8 +1763,8 @@ setindex!{T<:Integer}(A::SparseMatrixCSC, x::Number, I::AbstractVector{T}, j::In # Colon translation setindex!(A::SparseMatrixCSC, x, ::Colon) = setindex!(A, x, 1:length(A)) setindex!(A::SparseMatrixCSC, x, ::Colon, ::Colon) = setindex!(A, x, 1:size(A, 1), 1:size(A,2)) -setindex!(A::SparseMatrixCSC, x, ::Colon, j::Union(Integer, AbstractVector)) = setindex!(A, x, 1:size(A, 1), j) -setindex!(A::SparseMatrixCSC, x, i::Union(Integer, AbstractVector), ::Colon) = setindex!(A, x, i, 1:size(A, 2)) +setindex!(A::SparseMatrixCSC, x, ::Colon, j::Union{Integer, AbstractVector}) = setindex!(A, x, 1:size(A, 1), j) +setindex!(A::SparseMatrixCSC, x, i::Union{Integer, AbstractVector}, ::Colon) = setindex!(A, x, i, 1:size(A, 2)) setindex!{Tv,T<:Integer}(A::SparseMatrixCSC{Tv}, x::Number, I::AbstractVector{T}, J::AbstractVector{T}) = (0 == x) ? spdelete!(A, I, J) : spset!(A, convert(Tv,x), I, J) diff --git a/base/sparse/umfpack.jl b/base/sparse/umfpack.jl index 578addf188fbd..2a1e17c3628e8 100644 --- a/base/sparse/umfpack.jl +++ b/base/sparse/umfpack.jl @@ -60,13 +60,13 @@ end # check the size of SuiteSparse_long if Int(ccall((:jl_cholmod_sizeof_long,:libsuitesparse_wrapper),Csize_t,())) == 4 const UmfpackIndexTypes = (:Int32, ) - typealias UMFITypes Union(Int32) + typealias UMFITypes Union{Int32} else const UmfpackIndexTypes = (:Int32, :Int64) - typealias UMFITypes Union(Int32, Int64) + typealias UMFITypes Union{Int32, Int64} end -typealias UMFVTypes Union(Float64,Complex128) +typealias UMFVTypes Union{Float64,Complex128} ## UMFPACK diff --git a/base/special/gamma.jl b/base/special/gamma.jl index 11a06b8824e3d..0678287e1b064 100644 --- a/base/special/gamma.jl +++ b/base/special/gamma.jl @@ -67,7 +67,7 @@ gamma(z::Complex) = exp(lgamma(z)) # const A002445 = [1,6,30,42,30,66,2730,6,510,798,330,138,2730,6,870,14322,510,6,1919190,6,13530] # const bernoulli = A000367 .// A002445 # even-index Bernoulli numbers -function digamma(z::Union(Float64,Complex{Float64})) +function digamma(z::Union{Float64,Complex{Float64}}) # Based on eq. (12), without looking at the accompanying source # code, of: K. S. Kölbig, "Programs for computing the logarithm of # the gamma function, and the digamma function, for complex @@ -96,7 +96,7 @@ function digamma(z::Union(Float64,Complex{Float64})) ψ -= t * @evalpoly(t,0.08333333333333333,-0.008333333333333333,0.003968253968253968,-0.004166666666666667,0.007575757575757576,-0.021092796092796094,0.08333333333333333,-0.4432598039215686) end -function trigamma(z::Union(Float64,Complex{Float64})) +function trigamma(z::Union{Float64,Complex{Float64}}) # via the derivative of the Kölbig digamma formulation x = real(z) if x <= 0 # reflection formula @@ -237,8 +237,8 @@ inv_oftype(x::Real, y::Real) = oftype(x, inv(y)) # the zeta function for free and might as well export it, especially # since this is a common generalization of the Riemann zeta function # (which Julia already exports). -function zeta(s::Union(Int,Float64,Complex{Float64}), - z::Union(Float64,Complex{Float64})) +function zeta(s::Union{Int,Float64,Complex{Float64}}, + z::Union{Float64,Complex{Float64}}) ζ = zero(promote_type(typeof(s), typeof(z))) # like sqrt, require complex inputs to get complex outputs @@ -313,7 +313,7 @@ function zeta(s::Union(Int,Float64,Complex{Float64}), return ζ end -function polygamma(m::Integer, z::Union(Float64,Complex{Float64})) +function polygamma(m::Integer, z::Union{Float64,Complex{Float64}}) m == 0 && return digamma(z) m == 1 && return trigamma(z) @@ -352,12 +352,12 @@ f16(z::Complex) = Complex32(z) # Float32 version by truncating the Stirling series at a smaller cutoff. for (f,T) in ((:f32,Float32),(:f16,Float16)) @eval begin - zeta(s::Integer, z::Union($T,Complex{$T})) = $f(zeta(Int(s), f64(z))) - zeta(s::Union(Float64,Complex128), z::Union($T,Complex{$T})) = zeta(s, f64(z)) - zeta(s::Number, z::Union($T,Complex{$T})) = $f(zeta(f64(s), f64(z))) - polygamma(m::Integer, z::Union($T,Complex{$T})) = $f(polygamma(Int(m), f64(z))) - digamma(z::Union($T,Complex{$T})) = $f(digamma(f64(z))) - trigamma(z::Union($T,Complex{$T})) = $f(trigamma(f64(z))) + zeta(s::Integer, z::Union{$T,Complex{$T}}) = $f(zeta(Int(s), f64(z))) + zeta(s::Union{Float64,Complex128}, z::Union{$T,Complex{$T}}) = zeta(s, f64(z)) + zeta(s::Number, z::Union{$T,Complex{$T}}) = $f(zeta(f64(s), f64(z))) + polygamma(m::Integer, z::Union{$T,Complex{$T}}) = $f(polygamma(Int(m), f64(z))) + digamma(z::Union{$T,Complex{$T}}) = $f(digamma(f64(z))) + trigamma(z::Union{$T,Complex{$T}}) = $f(trigamma(f64(z))) end end @@ -414,7 +414,7 @@ lbeta(x::Number, w::Number) = lgamma(x)+lgamma(w)-lgamma(x+w) # Riemann zeta function; algorithm is based on specializing the Hurwitz # zeta function above for z==1. -function zeta(s::Union(Float64,Complex{Float64})) +function zeta(s::Union{Float64,Complex{Float64}}) # blows up to ±Inf, but get correct sign of imaginary zero s == 1 && return NaN + zero(s) * imag(s) @@ -464,7 +464,7 @@ zeta(x::Real) = oftype(float(x),zeta(Float64(x))) zeta(z::Complex) = oftype(float(z),zeta(Complex128(z))) @vectorize_1arg Number zeta -function eta(z::Union(Float64,Complex{Float64})) +function eta(z::Union{Float64,Complex{Float64}}) δz = 1 - z if abs(real(δz)) + abs(imag(δz)) < 7e-3 # Taylor expand around z==1 return 0.6931471805599453094172321214581765 * diff --git a/base/stat.jl b/base/stat.jl index f9b5cc684e090..cdad1ab9f93de 100644 --- a/base/stat.jl +++ b/base/stat.jl @@ -15,7 +15,7 @@ immutable StatStruct ctime :: Float64 end -StatStruct(buf::Union(Vector{UInt8},Ptr{UInt8})) = StatStruct( +StatStruct(buf::Union{Vector{UInt8},Ptr{UInt8}}) = StatStruct( ccall(:jl_stat_dev, UInt32, (Ptr{UInt8},), buf), ccall(:jl_stat_ino, UInt32, (Ptr{UInt8},), buf), ccall(:jl_stat_mode, UInt32, (Ptr{UInt8},), buf), diff --git a/base/statistics.jl b/base/statistics.jl index 76a00a7ed2397..a282f500f645c 100644 --- a/base/statistics.jl +++ b/base/statistics.jl @@ -26,7 +26,7 @@ end momenttype{T}(::Type{T}) = typeof((zero(T) + zero(T)) / 2) momenttype(::Type{Float32}) = Float32 -momenttype{T<:Union(Float64,Int32,Int64,UInt32,UInt64)}(::Type{T}) = Float64 +momenttype{T<:Union{Float64,Int32,Int64,UInt32,UInt64}}(::Type{T}) = Float64 mean{T}(A::AbstractArray{T}, region) = mean!(reducedim_initarray(A, region, 0, momenttype(T)), A) @@ -448,7 +448,7 @@ end ##### median & quantiles ##### # Specialized functions for real types allow for improved performance -middle(x::Union(Bool,Int8,Int16,Int32,Int64,Int128,UInt8,UInt16,UInt32,UInt64,UInt128)) = Float64(x) +middle(x::Union{Bool,Int8,Int16,Int32,Int64,Int128,UInt8,UInt16,UInt32,UInt64,UInt128}) = Float64(x) middle(x::FloatingPoint) = x middle(x::Float16) = Float32(x) middle(x::Real) = (x + zero(x)) / 1 diff --git a/base/stream.jl b/base/stream.jl index 12fbe0c031113..ee0f23b2ef338 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -6,7 +6,7 @@ include("uv_constants.jl") import .Libc: RawFD, dup ## types ## -typealias Callback Union(Function,Bool) +typealias Callback Union{Function,Bool} abstract AsyncStream <: IO abstract UVServer @@ -146,7 +146,7 @@ type PipeServer <: UVServer false,Condition()) end -function init_pipe!(pipe::Union(Pipe,PipeServer);readable::Bool=false,writable=false,julia_only=true) +function init_pipe!(pipe::Union{Pipe,PipeServer};readable::Bool=false,writable=false,julia_only=true) if pipe.handle == C_NULL error("failed to initialize pipe") elseif pipe.status != StatusUninit @@ -218,9 +218,9 @@ end # note that uv_is_readable/writable work for any subtype of # uv_stream_t, including uv_tty_t and uv_pipe_t -isreadable(io::Union(Pipe,TTY)) = +isreadable(io::Union{Pipe,TTY}) = ccall(:uv_is_readable, Cint, (Ptr{Void},), io.handle)!=0 -iswritable(io::Union(Pipe,TTY)) = +iswritable(io::Union{Pipe,TTY}) = ccall(:uv_is_writable, Cint, (Ptr{Void},), io.handle)!=0 nb_available(stream::UVStream) = nb_available(stream.buffer) @@ -298,7 +298,7 @@ function reinit_stdio() global STDERR = init_stdio(ccall(:jl_stderr_stream,Ptr{Void},())) end -function isopen{T<:Union(AsyncStream,UVServer)}(x::T) +function isopen{T<:Union{AsyncStream,UVServer}}(x::T) if !(x.status != StatusUninit && x.status != StatusInit) throw(ArgumentError("$T object not initialized")) end @@ -468,7 +468,7 @@ function reseteof(x::TTY) nothing end -function _uv_hook_close(uv::Union(AsyncStream,UVServer)) +function _uv_hook_close(uv::Union{AsyncStream,UVServer}) uv.handle = C_NULL uv.status = StatusClosed if isa(uv.closecb, Function) @@ -662,7 +662,7 @@ close_pipe_sync(handle::UVHandle) = ccall(:uv_pipe_close_sync,Void,(UVHandle,),h _uv_hook_isopen(stream) = Int32(stream.status != StatusUninit && stream.status != StatusInit && isopen(stream)) -function close(stream::Union(AsyncStream,UVServer)) +function close(stream::Union{AsyncStream,UVServer}) if isopen(stream) && stream.status != StatusClosing ccall(:jl_close_uv,Void,(Ptr{Void},),stream.handle) stream.status = StatusClosing diff --git a/base/string.jl b/base/string.jl index 01a52258380ae..1542296b8280d 100644 --- a/base/string.jl +++ b/base/string.jl @@ -38,13 +38,13 @@ bytestring() = "" bytestring(s::Vector{UInt8}) = bytestring(pointer(s),length(s)) bytestring(s::AbstractString...) = print_to_string(s...) -function bytestring(p::Union(Ptr{UInt8},Ptr{Int8})) +function bytestring(p::Union{Ptr{UInt8},Ptr{Int8}}) p == C_NULL ? throw(ArgumentError("cannot convert NULL to string")) : ccall(:jl_cstr_to_string, ByteString, (Ptr{UInt8},), p) end bytestring(s::Cstring) = bytestring(box(Ptr{Cchar}, unbox(Cstring,s))) -function bytestring(p::Union(Ptr{UInt8},Ptr{Int8}),len::Integer) +function bytestring(p::Union{Ptr{UInt8},Ptr{Int8}},len::Integer) p == C_NULL ? throw(ArgumentError("cannot convert NULL to string")) : ccall(:jl_pchar_to_string, ByteString, (Ptr{UInt8},Int), p, len) end @@ -181,7 +181,7 @@ function chr2ind(s::AbstractString, i::Integer) end end -typealias Chars Union(Char,AbstractVector{Char},Set{Char}) +typealias Chars Union{Char,AbstractVector{Char},Set{Char}} function search(s::AbstractString, c::Chars, i::Integer) if isempty(c) @@ -300,7 +300,7 @@ function _searchindex(s::Array, t::Array, i) 0 end -typealias ByteArray Union(Vector{UInt8},Vector{Int8}) +typealias ByteArray Union{Vector{UInt8},Vector{Int8}} searchindex(s::ByteArray, t::ByteArray, i) = _searchindex(s,t,i) searchindex(s::AbstractString, t::AbstractString, i::Integer) = _searchindex(s,t,i) @@ -678,7 +678,7 @@ end const memhash = UInt === UInt64 ? :memhash_seed : :memhash32_seed const memhash_seed = UInt === UInt64 ? 0x71e729fd56419c81 : 0x56419c81 -function hash{T<:ByteString}(s::Union(T,SubString{T}), h::UInt) +function hash{T<:ByteString}(s::Union{T,SubString{T}}, h::UInt) h += memhash_seed # note: use pointer(s) here (see #6058). ccall(memhash, UInt, (Ptr{UInt8}, Csize_t, UInt32), pointer(s), sizeof(s), h % UInt32) + h @@ -758,7 +758,7 @@ isascii(s::RevString{ASCIIString}) = true ## reverse an index i so that reverse(s)[i] == s[reverseind(s,i)] -reverseind(s::Union(DirectIndexString,SubString{DirectIndexString}), i::Integer) = length(s) + 1 - i +reverseind(s::Union{DirectIndexString,SubString{DirectIndexString}}, i::Integer) = length(s) + 1 - i reverseind(s::RevString, i::Integer) = endof(s) - i + 1 lastidx(s::AbstractString) = nextind(s, endof(s)) - 1 lastidx(s::DirectIndexString) = length(s) @@ -825,7 +825,7 @@ end ## string map, filter, has ## map_result(s::AbstractString, a::Vector{UInt8}) = UTF8String(a) -map_result(s::Union(ASCIIString,SubString{ASCIIString}), a::Vector{UInt8}) = bytestring(a) +map_result(s::Union{ASCIIString,SubString{ASCIIString}}, a::Vector{UInt8}) = bytestring(a) function map(f, s::AbstractString) out = IOBuffer(Array(UInt8,endof(s)),true,true) @@ -983,8 +983,8 @@ byte_string_classify(s::ByteString) = byte_string_classify(s.data) # 1: valid ASCII # 2: valid UTF-8 -isvalid(::Type{ASCIIString}, s::Union(Vector{UInt8},ByteString)) = byte_string_classify(s) == 1 -isvalid(::Type{UTF8String}, s::Union(Vector{UInt8},ByteString)) = byte_string_classify(s) != 0 +isvalid(::Type{ASCIIString}, s::Union{Vector{UInt8},ByteString}) = byte_string_classify(s) == 1 +isvalid(::Type{UTF8String}, s::Union{Vector{UInt8},ByteString}) = byte_string_classify(s) != 0 ## multiline strings ## @@ -1627,7 +1627,7 @@ parse{T<:Integer}(::Type{T}, s::AbstractString) = get(tryparse_internal(T, s, 0, ## stringifying integers more efficiently ## -string(x::Union(Int8,Int16,Int32,Int64,Int128)) = dec(x) +string(x::Union{Int8,Int16,Int32,Int64,Int128}) = dec(x) ## string to float functions ## @@ -1637,7 +1637,7 @@ tryparse{T<:ByteString}(::Type{Float64}, s::SubString{T}) = ccall(:jl_try_substr tryparse(::Type{Float32}, s::ByteString) = ccall(:jl_try_substrtof, Nullable{Float32}, (Ptr{UInt8},Csize_t,Csize_t), s, 0, sizeof(s)) tryparse{T<:ByteString}(::Type{Float32}, s::SubString{T}) = ccall(:jl_try_substrtof, Nullable{Float32}, (Ptr{UInt8},Csize_t,Csize_t), s.string, s.offset, s.endof) -tryparse{T<:Union(Float32,Float64)}(::Type{T}, s::AbstractString) = tryparse(T, bytestring(s)) +tryparse{T<:Union{Float32,Float64}}(::Type{T}, s::AbstractString) = tryparse(T, bytestring(s)) function parse{T<:FloatingPoint}(::Type{T}, s::AbstractString) nf = tryparse(T, s) @@ -1650,7 +1650,7 @@ float{S<:AbstractString}(a::AbstractArray{S}) = map!(float, similar(a,typeof(flo # find the index of the first occurrence of a value in a byte array -function search(a::ByteArray, b::Union(Int8,UInt8), i::Integer) +function search(a::ByteArray, b::Union{Int8,UInt8}, i::Integer) if i < 1 throw(BoundsError(a, i)) end @@ -1669,9 +1669,9 @@ function search(a::ByteArray, b::Char, i::Integer) search(a,string(b).data,i).start end end -search(a::ByteArray, b::Union(Int8,UInt8,Char)) = search(a,b,1) +search(a::ByteArray, b::Union{Int8,UInt8,Char}) = search(a,b,1) -function rsearch(a::ByteArray, b::Union(Int8,UInt8), i::Integer) +function rsearch(a::ByteArray, b::Union{Int8,UInt8}, i::Integer) if i < 1 return i == 0 ? 0 : throw(BoundsError(a, i)) end @@ -1690,7 +1690,7 @@ function rsearch(a::ByteArray, b::Char, i::Integer) rsearch(a,string(b).data,i).start end end -rsearch(a::ByteArray, b::Union(Int8,UInt8,Char)) = rsearch(a,b,length(a)) +rsearch(a::ByteArray, b::Union{Int8,UInt8,Char}) = rsearch(a,b,length(a)) function hex2bytes(s::ASCIIString) len = length(s) @@ -1724,7 +1724,7 @@ end containsnul(s::AbstractString) = '\0' in s containsnul(s::ByteString) = containsnul(unsafe_convert(Ptr{Cchar}, s), sizeof(s)) -containsnul(s::Union(UTF16String,UTF32String)) = findfirst(s.data, 0) != length(s.data) +containsnul(s::Union{UTF16String,UTF32String}) = findfirst(s.data, 0) != length(s.data) if sizeof(Cwchar_t) == 2 const WString = UTF16String @@ -1745,13 +1745,13 @@ function unsafe_convert(::Type{Cwstring}, s::WString) end # pointer conversions of ASCII/UTF8/UTF16/UTF32 strings: -pointer(x::Union(ByteString,UTF16String,UTF32String)) = pointer(x.data) +pointer(x::Union{ByteString,UTF16String,UTF32String}) = pointer(x.data) pointer{T<:ByteString}(x::SubString{T}) = pointer(x.string.data) + x.offset pointer(x::ByteString, i::Integer) = pointer(x.data)+(i-1) pointer{T<:ByteString}(x::SubString{T}, i::Integer) = pointer(x.string.data) + x.offset + (i-1) -pointer(x::Union(UTF16String,UTF32String), i::Integer) = pointer(x)+(i-1)*sizeof(eltype(x.data)) -pointer{T<:Union(UTF16String,UTF32String)}(x::SubString{T}) = pointer(x.string.data) + x.offset*sizeof(eltype(x.data)) -pointer{T<:Union(UTF16String,UTF32String)}(x::SubString{T}, i::Integer) = pointer(x.string.data) + (x.offset + (i-1))*sizeof(eltype(x.data)) +pointer(x::Union{UTF16String,UTF32String}, i::Integer) = pointer(x)+(i-1)*sizeof(eltype(x.data)) +pointer{T<:Union{UTF16String,UTF32String}}(x::SubString{T}) = pointer(x.string.data) + x.offset*sizeof(eltype(x.data)) +pointer{T<:Union{UTF16String,UTF32String}}(x::SubString{T}, i::Integer) = pointer(x.string.data) + (x.offset + (i-1))*sizeof(eltype(x.data)) # IOBuffer views of a (byte)string: IOBuffer(str::ByteString) = IOBuffer(str.data) diff --git a/base/subarray.jl b/base/subarray.jl index f9e18ffe461ab..0fceca29ea199 100644 --- a/base/subarray.jl +++ b/base/subarray.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license -typealias NonSliceIndex Union(Colon, Range{Int}, UnitRange{Int}, Array{Int,1}) -typealias ViewIndex Union(Int, NonSliceIndex) +typealias NonSliceIndex Union{Colon, Range{Int}, UnitRange{Int}, Array{Int,1}} +typealias ViewIndex Union{Int, NonSliceIndex} # LD is the last dimension up through which this object has efficient # linear indexing. If LD==length(I), then the object itself has efficient @@ -14,10 +14,10 @@ immutable SubArray{T,N,P<:AbstractArray,I<:Tuple{Vararg{ViewIndex}},LD} <: Abstr stride1::Int # used only for linear indexing end -typealias StridedArray{T,N,A<:DenseArray,I<:Tuple{Vararg{RangeIndex}}} Union(DenseArray{T,N}, SubArray{T,N,A,I}) -typealias StridedVector{T,A<:DenseArray,I<:Tuple{Vararg{RangeIndex}}} Union(DenseArray{T,1}, SubArray{T,1,A,I}) -typealias StridedMatrix{T,A<:DenseArray,I<:Tuple{Vararg{RangeIndex}}} Union(DenseArray{T,2}, SubArray{T,2,A,I}) -typealias StridedVecOrMat{T} Union(StridedVector{T}, StridedMatrix{T}) +typealias StridedArray{T,N,A<:DenseArray,I<:Tuple{Vararg{RangeIndex}}} Union{DenseArray{T,N}, SubArray{T,N,A,I}} +typealias StridedVector{T,A<:DenseArray,I<:Tuple{Vararg{RangeIndex}}} Union{DenseArray{T,1}, SubArray{T,1,A,I}} +typealias StridedMatrix{T,A<:DenseArray,I<:Tuple{Vararg{RangeIndex}}} Union{DenseArray{T,2}, SubArray{T,2,A,I}} +typealias StridedVecOrMat{T} Union{StridedVector{T}, StridedMatrix{T}} # Simple utilities eltype{T,N,P,I}(V::SubArray{T,N,P,I}) = T @@ -357,7 +357,7 @@ in(::Int, ::Colon) = true ## Strides @generated function strides{T,N,P,I}(V::SubArray{T,N,P,I}) Ip = I.parameters - all(map(x->x<:Union(RangeIndex,Colon), Ip)) || throw(ArgumentError("strides valid only for RangeIndex indexing")) + all(map(x->x<:Union{RangeIndex,Colon}, Ip)) || throw(ArgumentError("strides valid only for RangeIndex indexing")) strideexprs = Array(Any, N+1) strideexprs[1] = 1 i = 1 @@ -518,7 +518,7 @@ function parentdims(s::SubArray) j = 1 for i = 1:ndims(s.parent) r = s.indexes[i] - if j <= nd && (isa(r,Union(Colon,Range)) ? sp[i]*step(r) : sp[i]) == sv[j] + if j <= nd && (isa(r,Union{Colon,Range}) ? sp[i]*step(r) : sp[i]) == sv[j] dimindex[j] = i j += 1 end @@ -603,9 +603,9 @@ end # Indexing with non-scalars. For now, this returns a copy, but changing that # is just a matter of deleting the explicit call to copy. getindex{T,N,P,IV}(V::SubArray{T,N,P,IV}, I::ViewIndex...) = copy(sub(V, I...)) -getindex{T,N,P,IV}(V::SubArray{T,N,P,IV}, I::Union(Real, AbstractVector, Colon)...) = getindex(V, to_index(I)...) +getindex{T,N,P,IV}(V::SubArray{T,N,P,IV}, I::Union{Real, AbstractVector, Colon}...) = getindex(V, to_index(I)...) unsafe_getindex{T,N,P,IV}(V::SubArray{T,N,P,IV}, I::ViewIndex...) = copy(sub_unsafe(V, I)) -unsafe_getindex{T,N,P,IV}(V::SubArray{T,N,P,IV}, I::Union(Real, AbstractVector, Colon)...) = unsafe_getindex(V, to_index(I)...) +unsafe_getindex{T,N,P,IV}(V::SubArray{T,N,P,IV}, I::Union{Real, AbstractVector, Colon}...) = unsafe_getindex(V, to_index(I)...) # Nonscalar setindex! falls back to the AbstractArray versions diff --git a/base/utf16.jl b/base/utf16.jl index 11c22f9dde65e..8caa3fd14f19d 100644 --- a/base/utf16.jl +++ b/base/utf16.jl @@ -82,7 +82,7 @@ convert(::Type{UTF8String}, s::UTF16String) = sprint(length(s.data)-1, io->for c in s; write(io,c::Char); end) sizeof(s::UTF16String) = sizeof(s.data) - sizeof(UInt16) -unsafe_convert{T<:Union(Int16,UInt16)}(::Type{Ptr{T}}, s::UTF16String) = +unsafe_convert{T<:Union{Int16,UInt16}}(::Type{Ptr{T}}, s::UTF16String) = convert(Ptr{T}, pointer(s)) function isvalid(::Type{UTF16String}, data::AbstractArray{UInt16}) @@ -138,7 +138,7 @@ end utf16(p::Ptr{UInt16}, len::Integer) = utf16(pointer_to_array(p, len)) utf16(p::Ptr{Int16}, len::Integer) = utf16(convert(Ptr{UInt16}, p), len) -function utf16(p::Union(Ptr{UInt16}, Ptr{Int16})) +function utf16(p::Union{Ptr{UInt16}, Ptr{Int16}}) len = 0 while unsafe_load(p, len+1) != 0; len += 1; end utf16(p, len) diff --git a/base/utf32.jl b/base/utf32.jl index c12c396610131..b85213e747db1 100644 --- a/base/utf32.jl +++ b/base/utf32.jl @@ -25,7 +25,7 @@ function convert(::Type{UTF32String}, data::AbstractVector{Char}) UTF32String(copy!(d,1, data,1, len)) end -convert{T<:Union(Int32,UInt32)}(::Type{UTF32String}, data::AbstractVector{T}) = +convert{T<:Union{Int32,UInt32}}(::Type{UTF32String}, data::AbstractVector{T}) = convert(UTF32String, reinterpret(Char, data)) convert{T<:AbstractString}(::Type{T}, v::AbstractVector{Char}) = convert(T, utf32(v)) @@ -46,7 +46,7 @@ convert(::Type{Array{Char}}, s::UTF32String) = s.data reverse(s::UTF32String) = UTF32String(reverse!(copy(s.data), 1, length(s))) sizeof(s::UTF32String) = sizeof(s.data) - sizeof(Char) -unsafe_convert{T<:Union(Int32,UInt32,Char)}(::Type{Ptr{T}}, s::UTF32String) = +unsafe_convert{T<:Union{Int32,UInt32,Char}}(::Type{Ptr{T}}, s::UTF32String) = convert(Ptr{T}, pointer(s)) function convert(T::Type{UTF32String}, bytes::AbstractArray{UInt8}) @@ -70,7 +70,7 @@ function convert(T::Type{UTF32String}, bytes::AbstractArray{UInt8}) UTF32String(d) end -function isvalid(::Type{UTF32String}, str::Union(Vector{Char}, Vector{UInt32})) +function isvalid(::Type{UTF32String}, str::Union{Vector{Char}, Vector{UInt32}}) for i=1:length(str) @inbounds if !isvalid(Char, reinterpret(UInt32, str[i])) ; return false ; end end @@ -79,8 +79,8 @@ end isvalid(str::Vector{Char}) = isvalid(UTF32String, str) utf32(p::Ptr{Char}, len::Integer) = utf32(pointer_to_array(p, len)) -utf32(p::Union(Ptr{UInt32}, Ptr{Int32}), len::Integer) = utf32(convert(Ptr{Char}, p), len) -function utf32(p::Union(Ptr{Char}, Ptr{UInt32}, Ptr{Int32})) +utf32(p::Union{Ptr{UInt32}, Ptr{Int32}}, len::Integer) = utf32(convert(Ptr{Char}, p), len) +function utf32(p::Union{Ptr{Char}, Ptr{UInt32}, Ptr{Int32}}) len = 0 while unsafe_load(p, len+1) != 0; len += 1; end utf32(p, len) diff --git a/base/utf8.jl b/base/utf8.jl index e29abe6ffe218..e94a988777521 100644 --- a/base/utf8.jl +++ b/base/utf8.jl @@ -166,7 +166,7 @@ function string(a::ByteString...) UTF8String(data) end -function string(a::Union(ByteString,Char)...) +function string(a::Union{ByteString,Char}...) s = Array(UInt8,0) for d in a if isa(d,Char) diff --git a/base/utftypes.jl b/base/utftypes.jl index 749f1bd774832..86b360234e45c 100644 --- a/base/utftypes.jl +++ b/base/utftypes.jl @@ -30,5 +30,5 @@ immutable UTF32String <: DirectIndexString end UTF32String(data::Vector{UInt32}) = UTF32String(reinterpret(Char, data)) -isvalid{T<:Union(ASCIIString,UTF8String,UTF16String,UTF32String)}(str::T) = isvalid(T, str.data) -isvalid{T<:Union(ASCIIString,UTF8String,UTF16String,UTF32String)}(::Type{T}, str::T) = isvalid(T, str.data) +isvalid{T<:Union{ASCIIString,UTF8String,UTF16String,UTF32String}}(str::T) = isvalid(T, str.data) +isvalid{T<:Union{ASCIIString,UTF8String,UTF16String,UTF32String}}(::Type{T}, str::T) = isvalid(T, str.data) diff --git a/base/version.jl b/base/version.jl index c6bb1f663fa4d..1b87b57e54dbf 100644 --- a/base/version.jl +++ b/base/version.jl @@ -6,10 +6,10 @@ immutable VersionNumber major::Int minor::Int patch::Int - prerelease::Tuple{Vararg{Union(Int,ASCIIString)}} - build::Tuple{Vararg{Union(Int,ASCIIString)}} + prerelease::Tuple{Vararg{Union{Int,ASCIIString}}} + build::Tuple{Vararg{Union{Int,ASCIIString}}} - function VersionNumber(major::Integer, minor::Integer, patch::Integer, pre::Tuple{Vararg{Union(Int,ASCIIString)}}, bld::Tuple{Vararg{Union(Int,ASCIIString)}}) + function VersionNumber(major::Integer, minor::Integer, patch::Integer, pre::Tuple{Vararg{Union{Int,ASCIIString}}}, bld::Tuple{Vararg{Union{Int,ASCIIString}}}) major >= 0 || throw(ArgumentError("invalid negative major version: $major")) minor >= 0 || throw(ArgumentError("invalid negative minor version: $minor")) patch >= 0 || throw(ArgumentError("invalid negative patch version: $patch")) @@ -108,8 +108,8 @@ ident_cmp(a::Int, b::ASCIIString) = isempty(b) ? +1 : -1 ident_cmp(a::ASCIIString, b::Int) = isempty(a) ? -1 : +1 ident_cmp(a::ASCIIString, b::ASCIIString) = cmp(a,b) -function ident_cmp(A::Tuple{Vararg{Union(Int,ASCIIString)}}, - B::Tuple{Vararg{Union(Int,ASCIIString)}}) +function ident_cmp(A::Tuple{Vararg{Union{Int,ASCIIString}}}, + B::Tuple{Vararg{Union{Int,ASCIIString}}}) i = start(A) j = start(B) while !done(A,i) && !done(B,i) diff --git a/test/arrayops.jl b/test/arrayops.jl index be01e2b0979c7..057414fa418f8 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -765,7 +765,7 @@ fill!(S, 3) @test A == [1 1 3; 2 2 3; 1 1 1] rt = Base.return_types(fill!, Tuple{Array{Int32, 3}, UInt8}) @test length(rt) == 1 && rt[1] == Array{Int32, 3} -A = Array(Union(UInt8,Int8), 3) +A = Array(Union{UInt8,Int8}, 3) fill!(A, UInt8(3)) @test A == [0x03, 0x03, 0x03] # Issue #9964 diff --git a/test/bitarray.jl b/test/bitarray.jl index 2d5ca31375eba..2773e8c7ae5fc 100644 --- a/test/bitarray.jl +++ b/test/bitarray.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license tc{N}(r1::NTuple{N}, r2::NTuple{N}) = all(map(x->tc(x...), [zip(r1,r2)...])) -tc{N}(r1::BitArray{N}, r2::Union(BitArray{N},Array{Bool,N})) = true +tc{N}(r1::BitArray{N}, r2::Union{BitArray{N},Array{Bool,N}}) = true tc{T}(r1::T, r2::T) = true tc(r1,r2) = false diff --git a/test/core.jl b/test/core.jl index 3b655267b6ed8..6bd52e811631f 100644 --- a/test/core.jl +++ b/test/core.jl @@ -2,7 +2,7 @@ # test core language features -const Bottom = Union() +const Bottom = Union{} function testintersect(a, b, result, cmp=is) @test cmp(typeintersect(a, b), result) @@ -28,8 +28,8 @@ isnot(x,y) = !is(x,y) @test !(Array{Any,1} <: Array{Int8,1}) @test Array{Int8,1} <: Array{Int8,1} @test !(Type{Bottom} <: Type{Int32}) -@test !(Vector{Float64} <: Vector{Union(Float64,Float32)}) -testintersect(Vector{Float64}, Vector{Union(Float64,Float32)}, Bottom) +@test !(Vector{Float64} <: Vector{Union{Float64,Float32}}) +testintersect(Vector{Float64}, Vector{Union{Float64,Float32}}, Bottom) @test !isa(Array,Type{Any}) @test Type{Complex} <: DataType @@ -57,8 +57,8 @@ let T = TypeVar(:T,true) f47{T}(x::Vector{Vector{T}}) = 0 @test_throws MethodError f47(Array(Vector,0)) @test f47(Array(Vector{Int},0)) == 0 - testintersect(Tuple{T,T}, Tuple{Union(Float64,Int64),Int64}, Tuple{Int64,Int64}) - testintersect(Tuple{T,T}, Tuple{Int64,Union(Float64,Int64)}, Tuple{Int64,Int64}) + testintersect(Tuple{T,T}, Tuple{Union{Float64,Int64},Int64}, Tuple{Int64,Int64}) + testintersect(Tuple{T,T}, Tuple{Int64,Union{Float64,Int64}}, Tuple{Int64,Int64}) TT = TypeVar(:T) S = TypeVar(:S,true); N = TypeVar(:N,true); SN = TypeVar(:S,Number,true) @@ -114,10 +114,10 @@ testintersect(Tuple{Vararg{Int}}, Tuple{Vararg{Bool}}, Tuple{}) testintersect(Type{Tuple{Vararg{Int}}}, Type{Tuple{Vararg{Bool}}}, Bottom) testintersect(Tuple{Bool,Vararg{Int}}, Tuple{Vararg{Bool}}, Tuple{Bool,}) -let T = TypeVar(:T,Union(Float32,Float64)) +let T = TypeVar(:T,Union{Float32,Float64}) testintersect(AbstractArray, Matrix{T}, Matrix{T}) end -let T = TypeVar(:T,Union(Float32,Float64),true) +let T = TypeVar(:T,Union{Float32,Float64},true) testintersect(AbstractArray, Matrix{T}, Matrix{T}) end @@ -143,13 +143,13 @@ end @test !issubtype(Type{Tuple{Void}}, Tuple{Type{Void}}) # this is fancy: know that any type T<:Number must be either a DataType or a UnionType -@test Type{TypeVar(:T,Number)} <: Union(DataType,UnionType) +@test Type{TypeVar(:T,Number)} <: Union{DataType,UnionType} @test !(Type{TypeVar(:T,Number)} <: DataType) -@test !(Type{TypeVar(:T,Tuple)} <: Union(Tuple,UnionType)) -@test Type{TypeVar(:T,Tuple)} <: Union(DataType,UnionType) +@test !(Type{TypeVar(:T,Tuple)} <: Union{Tuple,UnionType}) +@test Type{TypeVar(:T,Tuple)} <: Union{DataType,UnionType} # issue #2997 -let T = TypeVar(:T,Union(Float64,Array{Float64,1}),true) +let T = TypeVar(:T,Union{Float64,Array{Float64,1}},true) testintersect(T,Real,Float64) end @@ -189,8 +189,8 @@ end Tuple{Int8,Vararg{Signed}}) @test Base.typeseq(typejoin(Tuple{Int8,UInt8,Vararg{Int}},Tuple{Int8,Vararg{Int8}}), Tuple{Int8,Vararg{Integer}}) -@test Base.typeseq(typejoin(Union(Int,AbstractString),Int), Union(Int,AbstractString)) -@test Base.typeseq(typejoin(Union(Int,AbstractString),Int8), Any) +@test Base.typeseq(typejoin(Union{Int,AbstractString},Int), Union{Int,AbstractString}) +@test Base.typeseq(typejoin(Union{Int,AbstractString},Int8), Any) # typejoin associativity abstract Foo____{K} @@ -738,10 +738,10 @@ end # issue #814 begin local MatOrNot, my_func, M - typealias MatOrNot{T} Union(AbstractMatrix{T}, Vector{Union()}) + typealias MatOrNot{T} Union{AbstractMatrix{T}, Vector{Union{}}} my_func{T<:Real}(A::MatOrNot{T}, B::MatOrNot{T}, C::MatOrNot{T}) = 0 M = [ 2. 1. ; 1. 1. ] - @test my_func(Union()[], M, M) == 0 + @test my_func(Union{}[], M, M) == 0 end begin @@ -1010,7 +1010,7 @@ end # issue #2365 type B2365{T} - v::Union(T, Void) + v::Union{T, Void} end @test B2365{Int}(nothing).v === nothing @test B2365{Int}(0).v === 0 @@ -1180,7 +1180,7 @@ function foo(x) end return ret end -let x = Array(Union(Dict{Int64,AbstractString},Array{Int64,3},Number,AbstractString,Void), 3) +let x = Array(Union{Dict{Int64,AbstractString},Array{Int64,3},Number,AbstractString,Void}, 3) x[1] = 1.0 x[2] = 2.0 x[3] = 3.0 @@ -1191,7 +1191,7 @@ end # issue #4115 #type Foo4115 #end -#typealias Foo4115s NTuple{3,Union(Foo4115,Type{Foo4115})} +#typealias Foo4115s NTuple{3,Union{Foo4115,Type{Foo4115}}} #baz4115(x::Foo4115s) = x #@test baz4115(convert(Tuple{Type{Foo4115},Type{Foo4115},Foo4115}, # (Foo4115,Foo4115,Foo4115()))) == (Foo4115,Foo4115,Foo4115()) @@ -1273,10 +1273,10 @@ end type A4413 end type B4413 end type C4413 end -f4413(::Union(A4413, B4413, C4413)) = "ABC" -f4413(::Union(A4413, B4413)) = "AB" -g4413(::Union(A4413, C4413)) = "AC" -g4413(::Union(A4413, B4413, C4413)) = "ABC" +f4413(::Union{A4413, B4413, C4413}) = "ABC" +f4413(::Union{A4413, B4413}) = "AB" +g4413(::Union{A4413, C4413}) = "AC" +g4413(::Union{A4413, B4413, C4413}) = "ABC" @test f4413(A4413()) == "AB" && f4413(B4413()) == "AB" @test g4413(A4413()) == "AC" && g4413(C4413()) == "AC" @@ -1314,8 +1314,8 @@ end @test_throws ErrorException f4528(true, Int32(12)) # issue #4518 -f4518(x, y::Union(Int32,Int64)) = 0 -f4518(x::ASCIIString, y::Union(Int32,Int64)) = 1 +f4518(x, y::Union{Int32,Int64}) = 0 +f4518(x::ASCIIString, y::Union{Int32,Int64}) = 1 @test f4518("",1) == 1 # issue #4581 @@ -1696,8 +1696,8 @@ x6074 = 6074 @test @X6074() == 6074 # issue #5536 -test5536(a::Union(Real, AbstractArray)...) = "Splatting" -test5536(a::Union(Real, AbstractArray)) = "Non-splatting" +test5536(a::Union{Real, AbstractArray}...) = "Splatting" +test5536(a::Union{Real, AbstractArray}) = "Non-splatting" @test test5536(5) == "Non-splatting" # multiline comments (#6139 and others raised in #6128) and embedded NUL chars (#10994) @@ -1886,19 +1886,19 @@ end # issue #6980 abstract A6980 type B6980 <: A6980 end -f6980(::Union(Int, Float64), ::A6980) = false -f6980(::Union(Int, Float64), ::B6980) = true +f6980(::Union{Int, Float64}, ::A6980) = false +f6980(::Union{Int, Float64}, ::B6980) = true @test f6980(1, B6980()) # issue #7049 -typealias Maybe7049{T} Union(T,Void) -function ttt7049(;init::Maybe7049{Union(AbstractString,Tuple{Int,Char})} = nothing) +typealias Maybe7049{T} Union{T,Void} +function ttt7049(;init::Maybe7049{Union{AbstractString,Tuple{Int,Char}}} = nothing) string("init=", init) end @test ttt7049(init="a") == "init=a" # issue #7074 -let z{T<:Union(Float64,Complex{Float64},Float32,Complex{Float32})}(A::StridedMatrix{T}) = T, +let z{T<:Union{Float64,Complex{Float64},Float32,Complex{Float32}}}(A::StridedMatrix{T}) = T, S = zeros(Complex,2,2) @test_throws MethodError z(S) end @@ -2311,7 +2311,7 @@ f7221(::AbstractVecOrMat) = 3 arithtype9232{T<:Real}(::Type{T},::Type{T}) = arithtype9232(T) result_type9232{T1<:Number,T2<:Number}(::Type{T1}, ::Type{T2}) = arithtype9232(T1, T2) # this gave a "type too large", but not reliably -@test length(code_typed(result_type9232, Tuple{Type{TypeVar(:_, Union(Float32,Float64))}, Type{TypeVar(:T2, Number)}})) == 1 +@test length(code_typed(result_type9232, Tuple{Type{TypeVar(:_, Union{Float32,Float64})}, Type{TypeVar(:T2, Number)}})) == 1 # test functionality of non-power-of-2 bitstype constants bitstype 24 Int24 @@ -2945,7 +2945,7 @@ immutable T11675{T} x::T T11675() = new() end -let x = T11675{Union()}() +let x = T11675{Union{}}() function f11675(x) x.x + 1 end diff --git a/test/functional.jl b/test/functional.jl index 18f53d2d30eae..9df37f2d4c52f 100644 --- a/test/functional.jl +++ b/test/functional.jl @@ -21,7 +21,7 @@ end # map over Bottom[] should return Bottom[] # issue #6719 -@test isequal(typeof(map(x -> x, Array(Union(),0))), Array{Union(),1}) +@test isequal(typeof(map(x -> x, Array(Union{},0))), Array{Union{},1}) # maps of tuples (formerly in test/core.jl) -- tuple.jl @test map((x,y)->x+y,(1,2,3),(4,5,6)) == (5,7,9) diff --git a/test/linalg2.jl b/test/linalg2.jl index e9fb49ebb36ef..4b08dd3ea6bb2 100644 --- a/test/linalg2.jl +++ b/test/linalg2.jl @@ -272,10 +272,10 @@ for elty in (Float32, Float64, BigFloat, Complex{Float32}, Complex{Float64}, Com A = ones(elty,10,10) As = sub(A,1:5,1:5) @test_approx_eq norm(A, 1) 10 - elty <: Union(BigFloat,Complex{BigFloat},BigInt) || @test_approx_eq norm(A, 2) 10 + elty <: Union{BigFloat,Complex{BigFloat},BigInt} || @test_approx_eq norm(A, 2) 10 @test_approx_eq norm(A, Inf) 10 @test_approx_eq norm(As, 1) 5 - elty <: Union(BigFloat,Complex{BigFloat},BigInt) || @test_approx_eq norm(As, 2) 5 + elty <: Union{BigFloat,Complex{BigFloat},BigInt} || @test_approx_eq norm(As, 2) 5 @test_approx_eq norm(As, Inf) 5 for i = 1:10 @@ -293,20 +293,20 @@ for elty in (Float32, Float64, BigFloat, Complex{Float32}, Complex{Float64}, Com # Absolute homogeneity @test_approx_eq norm(α*A,1) abs(α)*norm(A,1) - elty <: Union(BigFloat,Complex{BigFloat},BigInt) || @test_approx_eq norm(α*A) abs(α)*norm(A) # two is default + elty <: Union{BigFloat,Complex{BigFloat},BigInt} || @test_approx_eq norm(α*A) abs(α)*norm(A) # two is default @test_approx_eq norm(α*A,Inf) abs(α)*norm(A,Inf) @test_approx_eq norm(α*As,1) abs(α)*norm(As,1) - elty <: Union(BigFloat,Complex{BigFloat},BigInt) || @test_approx_eq norm(α*As) abs(α)*norm(As) # two is default + elty <: Union{BigFloat,Complex{BigFloat},BigInt} || @test_approx_eq norm(α*As) abs(α)*norm(As) # two is default @test_approx_eq norm(α*As,Inf) abs(α)*norm(As,Inf) # Triangle inequality @test norm(A + B,1) <= norm(A,1) + norm(B,1) - elty <: Union(BigFloat,Complex{BigFloat},BigInt) || @test norm(A + B) <= norm(A) + norm(B) # two is default + elty <: Union{BigFloat,Complex{BigFloat},BigInt} || @test norm(A + B) <= norm(A) + norm(B) # two is default @test norm(A + B,Inf) <= norm(A,Inf) + norm(B,Inf) @test norm(As + Bs,1) <= norm(As,1) + norm(Bs,1) - elty <: Union(BigFloat,Complex{BigFloat},BigInt) || @test norm(As + Bs) <= norm(As) + norm(Bs) # two is default + elty <: Union{BigFloat,Complex{BigFloat},BigInt} || @test norm(As + Bs) <= norm(As) + norm(Bs) # two is default @test norm(As + Bs,Inf) <= norm(As,Inf) + norm(Bs,Inf) # vecnorm: diff --git a/test/numbers.jl b/test/numbers.jl index 2081aae74c351..3d3e79355b432 100644 --- a/test/numbers.jl +++ b/test/numbers.jl @@ -646,7 +646,7 @@ for x=-5:5, y=-5:5 end end -function _cmp_(x::Union(Int64,UInt64), y::Float64) +function _cmp_(x::Union{Int64,UInt64}, y::Float64) if x==Int64(2)^53-2 && y==2.0^53-2; return 0; end if x==Int64(2)^53-2 && y==2.0^53-1; return -1; end if x==Int64(2)^53-2 && y==2.0^53 ; return -1; end diff --git a/test/perf/array/indexing.jl b/test/perf/array/indexing.jl index ca35ad357e8d3..ac436477150cf 100644 --- a/test/perf/array/indexing.jl +++ b/test/perf/array/indexing.jl @@ -136,9 +136,9 @@ Base.size(A::MyArray) = size(A.data) @inline Base.getindex(A::ArrayLF, i::Int) = getindex(A.data, i) @inline Base.getindex(A::ArrayLF, i::Int, i2::Int) = getindex(A.data, i, i2) -@inline Base.getindex(A::Union(ArrayLS, ArrayLSLS), i::Int, j::Int) = getindex(A.data, i, j) +@inline Base.getindex(A::Union{ArrayLS, ArrayLSLS}, i::Int, j::Int) = getindex(A.data, i, j) @inline Base.unsafe_getindex(A::ArrayLF, indx::Int) = unsafe_getindex(A.data, indx) -@inline Base.unsafe_getindex(A::Union(ArrayLS, ArrayLSLS), i::Int, j::Int) = unsafe_getindex(A.data, i, j) +@inline Base.unsafe_getindex(A::Union{ArrayLS, ArrayLSLS}, i::Int, j::Int) = unsafe_getindex(A.data, i, j) @inline Base.getindex{T}(A::ArrayStrides{T,2}, i::Real, j::Real) = getindex(A.data, 1+A.strides[1]*(i-1)+A.strides[2]*(j-1)) @inline Base.getindex(A::ArrayStrides1, i::Real, j::Real) = getindex(A.data, i + A.stride1*(j-1)) diff --git a/test/reducedim.jl b/test/reducedim.jl index e2429fdb5775d..afa1b4f655a8a 100644 --- a/test/reducedim.jl +++ b/test/reducedim.jl @@ -100,8 +100,8 @@ A = reshape(1:6, 3, 2) @test typeof(@inferred(Base.prod(Base.Abs2Fun(), [1.0+1.0im], 1))) == Vector{Float64} # Heterogeneously typed arrays -@test sum(Union(Float32, Float64)[1.0], 1) == [1.0] -@test prod(Union(Float32, Float64)[1.0], 1) == [1.0] +@test sum(Union{Float32, Float64}[1.0], 1) == [1.0] +@test prod(Union{Float32, Float64}[1.0], 1) == [1.0] @test reducedim((a,b) -> a|b, [true false; false false], 1, false) == [true false] R = reducedim((a,b) -> a+b, [1 2; 3 4], 2, 0.0) diff --git a/test/statistics.jl b/test/statistics.jl index 067adacb0444a..61cfcece0120a 100644 --- a/test/statistics.jl +++ b/test/statistics.jl @@ -250,7 +250,7 @@ end # test hist @test sum(hist([1,2,3])[2]) == 3 -@test hist(Union()[])[2] == [] +@test hist(Union{}[])[2] == [] @test hist([1])[2] == [1] @test hist([1,2,3],[0,2,4]) == ([0,2,4],[2,1]) @test hist([1,2,3],0:2:4) == (0:2:4,[2,1]) diff --git a/test/tuple.jl b/test/tuple.jl index d4e7b4168fae8..f2e1bc4dee939 100644 --- a/test/tuple.jl +++ b/test/tuple.jl @@ -56,7 +56,7 @@ @test eltype((1.0,2.0,3.0)) <: FloatingPoint @test eltype((true, false)) === Bool @test eltype((1,2.0, false)) === Any -@test eltype(()) === Union() +@test eltype(()) === Union{} ## mapping ##