Skip to content

Commit

Permalink
switch remaining files to where syntax (JuliaLang#11310)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored and jeffwong committed Jul 24, 2017
1 parent 2039b67 commit c5eae3d
Show file tree
Hide file tree
Showing 30 changed files with 123 additions and 123 deletions.
2 changes: 1 addition & 1 deletion examples/lru.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function setindex!(lru::LRU, v, key)
end

# Eviction
function setindex!{V,K}(lru::BoundedLRU, v::V, key::K)
function setindex!(lru::BoundedLRU, v::V, key::K) where {V,K}
invoke(setindex!, Tuple{LRU,V,K}, lru, v, key)
nrm = length(lru) - lru.maxsize
for i in 1:nrm
Expand Down
4 changes: 2 additions & 2 deletions examples/lru_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ TestBLRU = LRUExample.BoundedLRU{String, String}(1000)

get_str(i) = String(vcat(map(x->[x>>4; x&0x0F], reinterpret(UInt8, [Int32(i)]))...))

isbounded{L<:LRUExample.LRU}(::Type{L}) = any(map(n->n==:maxsize, fieldnames(L)))
isbounded{L<:LRUExample.LRU}(l::L) = isbounded(L)
isbounded(::Type{L}) where {L<:LRUExample.LRU} = any(map(n->n==:maxsize, fieldnames(L)))
isbounded(l::L) where {L<:LRUExample.LRU} = isbounded(L)

nmax = round.(Int, logspace(2, 5, 4))

Expand Down
22 changes: 11 additions & 11 deletions test/TestHelpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ struct OffsetArray{T,N,AA<:AbstractArray} <: AbstractArray{T,N}
end
OffsetVector{T,AA<:AbstractArray} = OffsetArray{T,1,AA}

OffsetArray{T,N}(A::AbstractArray{T,N}, offsets::NTuple{N,Int}) = OffsetArray{T,N,typeof(A)}(A, offsets)
OffsetArray{T,N}(A::AbstractArray{T,N}, offsets::Vararg{Int,N}) = OffsetArray(A, offsets)
OffsetArray(A::AbstractArray{T,N}, offsets::NTuple{N,Int}) where {T,N} = OffsetArray{T,N,typeof(A)}(A, offsets)
OffsetArray(A::AbstractArray{T,N}, offsets::Vararg{Int,N}) where {T,N} = OffsetArray(A, offsets)

(::Type{OffsetArray{T,N}}){T,N}(inds::Indices{N}) = OffsetArray{T,N,Array{T,N}}(Array{T,N}(map(length, inds)), map(indsoffset, inds))
(::Type{OffsetArray{T}}){T,N}(inds::Indices{N}) = OffsetArray{T,N}(inds)
(::Type{OffsetArray{T,N}})(inds::Indices{N}) where {T,N} = OffsetArray{T,N,Array{T,N}}(Array{T,N}(map(length, inds)), map(indsoffset, inds))
(::Type{OffsetArray{T}})(inds::Indices{N}) where {T,N} = OffsetArray{T,N}(inds)

Base.IndexStyle{T<:OffsetArray}(::Type{T}) = Base.IndexStyle(parenttype(T))
parenttype{T,N,AA}(::Type{OffsetArray{T,N,AA}}) = AA
Base.IndexStyle(::Type{T}) where {T<:OffsetArray} = Base.IndexStyle(parenttype(T))
parenttype(::Type{OffsetArray{T,N,AA}}) where {T,N,AA} = AA
parenttype(A::OffsetArray) = parenttype(typeof(A))

Base.parent(A::OffsetArray) = A.parent
Expand All @@ -151,7 +151,7 @@ Base.eachindex(::IndexLinear, A::OffsetVector) = indices(A, 1)
@inline Base.indices(A::OffsetArray) = _indices(indices(parent(A)), A.offsets) # would rather use ntuple, but see #15276
@inline _indices(inds, offsets) = (inds[1]+offsets[1], _indices(tail(inds), tail(offsets))...)
_indices(::Tuple{}, ::Tuple{}) = ()
Base.indices1{T}(A::OffsetArray{T,0}) = 1:1 # we only need to specialize this one
Base.indices1(A::OffsetArray{T,0}) where {T} = 1:1 # we only need to specialize this one

function Base.similar(A::OffsetArray, T::Type, dims::Dims)
B = similar(parent(A), T, dims)
Expand All @@ -165,7 +165,7 @@ Base.similar(f::Union{Function,Type}, shape::Tuple{UnitRange,Vararg{UnitRange}})

Base.reshape(A::AbstractArray, inds::Tuple{UnitRange,Vararg{UnitRange}}) = OffsetArray(reshape(A, map(length, inds)), map(indsoffset, inds))

@inline function Base.getindex{T,N}(A::OffsetArray{T,N}, I::Vararg{Int,N})
@inline function Base.getindex(A::OffsetArray{T,N}, I::Vararg{Int,N}) where {T,N}
checkbounds(A, I...)
@inbounds ret = parent(A)[offset(A.offsets, I)...]
ret
Expand All @@ -182,7 +182,7 @@ end
@inbounds ret = parent(A)[i]
ret
end
@inline function Base.setindex!{T,N}(A::OffsetArray{T,N}, val, I::Vararg{Int,N})
@inline function Base.setindex!(A::OffsetArray{T,N}, val, I::Vararg{Int,N}) where {T,N}
checkbounds(A, I...)
@inbounds parent(A)[offset(A.offsets, I)...] = val
val
Expand All @@ -203,7 +203,7 @@ end
@inbounds deleteat!(parent(A), offset(A.offsets, (i,))[1])
end

@inline function Base.deleteat!{T,N}(A::OffsetArray{T,N}, I::Vararg{Int, N})
@inline function Base.deleteat!(A::OffsetArray{T,N}, I::Vararg{Int, N}) where {T,N}
checkbounds(A, I...)
@inbounds deleteat!(parent(A), offset(A.offsets, I)...)
end
Expand All @@ -217,7 +217,7 @@ end
end

# Computing a shifted index (subtracting the offset)
offset{N}(offsets::NTuple{N,Int}, inds::NTuple{N,Int}) = _offset((), offsets, inds)
offset(offsets::NTuple{N,Int}, inds::NTuple{N,Int}) where {N} = _offset((), offsets, inds)
_offset(out, ::Tuple{}, ::Tuple{}) = out
@inline _offset(out, offsets, inds) = _offset((out..., inds[1]-offsets[1]), Base.tail(offsets), Base.tail(inds))

Expand Down
74 changes: 37 additions & 37 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,28 +202,28 @@ end
T24Linear(::Type{T}, dims::Int...) where T = T24Linear(T, dims)
T24Linear(::Type{T}, dims::NTuple{N,Int}) where {T,N} = T24Linear{T,N,dims}()

Base.convert{T,N }(::Type{T24Linear }, X::AbstractArray{T,N}) = convert(T24Linear{T,N}, X)
Base.convert{T,N,_}(::Type{T24Linear{T }}, X::AbstractArray{_,N}) = convert(T24Linear{T,N}, X)
Base.convert{T,N }(::Type{T24Linear{T,N}}, X::AbstractArray ) = T24Linear{T,N,size(X)}(X...)
Base.convert(::Type{T24Linear }, X::AbstractArray{T,N}) where {T,N } = convert(T24Linear{T,N}, X)
Base.convert(::Type{T24Linear{T }}, X::AbstractArray{_,N}) where {T,N,_} = convert(T24Linear{T,N}, X)
Base.convert(::Type{T24Linear{T,N}}, X::AbstractArray ) where {T,N } = T24Linear{T,N,size(X)}(X...)

Base.size{T,N,dims}(::T24Linear{T,N,dims}) = dims
Base.size(::T24Linear{T,N,dims}) where {T,N,dims} = dims
import Base: IndexLinear
Base.IndexStyle{A<:T24Linear}(::Type{A}) = IndexLinear()
Base.IndexStyle(::Type{A}) where {A<:T24Linear} = IndexLinear()
Base.getindex(A::T24Linear, i::Int) = getfield(A, i)
Base.setindex!{T}(A::T24Linear{T}, v, i::Int) = setfield!(A, i, convert(T, v))
Base.setindex!(A::T24Linear{T}, v, i::Int) where {T} = setfield!(A, i, convert(T, v))

# A custom linear slow sparse-like array that relies upon Dict for its storage
struct TSlow{T,N} <: AbstractArray{T,N}
data::Dict{NTuple{N,Int}, T}
dims::NTuple{N,Int}
end
TSlow{T}(::Type{T}, dims::Int...) = TSlow(T, dims)
TSlow{T,N}(::Type{T}, dims::NTuple{N,Int}) = TSlow{T,N}(Dict{NTuple{N,Int}, T}(), dims)
TSlow(::Type{T}, dims::Int...) where {T} = TSlow(T, dims)
TSlow(::Type{T}, dims::NTuple{N,Int}) where {T,N} = TSlow{T,N}(Dict{NTuple{N,Int}, T}(), dims)

Base.convert{T,N }(::Type{TSlow{T,N}}, X::TSlow{T,N}) = X
Base.convert{T,N }(::Type{TSlow }, X::AbstractArray{T,N}) = convert(TSlow{T,N}, X)
Base.convert{T,N,_}(::Type{TSlow{T }}, X::AbstractArray{_,N}) = convert(TSlow{T,N}, X)
Base.convert{T,N }(::Type{TSlow{T,N}}, X::AbstractArray ) = begin
Base.convert(::Type{TSlow{T,N}}, X::TSlow{T,N}) where {T,N } = X
Base.convert(::Type{TSlow }, X::AbstractArray{T,N}) where {T,N } = convert(TSlow{T,N}, X)
Base.convert(::Type{TSlow{T }}, X::AbstractArray{_,N}) where {T,N,_} = convert(TSlow{T,N}, X)
Base.convert(::Type{TSlow{T,N}}, X::AbstractArray ) where {T,N } = begin
A = TSlow(T, size(X))
for I in CartesianRange(size(X))
A[I.I...] = X[I.I...]
Expand All @@ -232,32 +232,32 @@ Base.convert{T,N }(::Type{TSlow{T,N}}, X::AbstractArray ) = begin
end

Base.size(A::TSlow) = A.dims
Base.similar{T}(A::TSlow, ::Type{T}, dims::Dims) = TSlow(T, dims)
Base.similar(A::TSlow, ::Type{T}, dims::Dims) where {T} = TSlow(T, dims)
import Base: IndexCartesian
Base.IndexStyle{A<:TSlow}(::Type{A}) = IndexCartesian()
Base.IndexStyle(::Type{A}) where {A<:TSlow} = IndexCartesian()
# Until #11242 is merged, we need to define each dimension independently
Base.getindex{T}(A::TSlow{T,0}) = get(A.data, (), zero(T))
Base.getindex{T}(A::TSlow{T,1}, i1::Int) = get(A.data, (i1,), zero(T))
Base.getindex{T}(A::TSlow{T,2}, i1::Int, i2::Int) = get(A.data, (i1,i2), zero(T))
Base.getindex{T}(A::TSlow{T,3}, i1::Int, i2::Int, i3::Int) =
Base.getindex(A::TSlow{T,0}) where {T} = get(A.data, (), zero(T))
Base.getindex(A::TSlow{T,1}, i1::Int) where {T} = get(A.data, (i1,), zero(T))
Base.getindex(A::TSlow{T,2}, i1::Int, i2::Int) where {T} = get(A.data, (i1,i2), zero(T))
Base.getindex(A::TSlow{T,3}, i1::Int, i2::Int, i3::Int) where {T} =
get(A.data, (i1,i2,i3), zero(T))
Base.getindex{T}(A::TSlow{T,4}, i1::Int, i2::Int, i3::Int, i4::Int) =
Base.getindex(A::TSlow{T,4}, i1::Int, i2::Int, i3::Int, i4::Int) where {T} =
get(A.data, (i1,i2,i3,i4), zero(T))
Base.getindex{T}(A::TSlow{T,5}, i1::Int, i2::Int, i3::Int, i4::Int, i5::Int) =
Base.getindex(A::TSlow{T,5}, i1::Int, i2::Int, i3::Int, i4::Int, i5::Int) where {T} =
get(A.data, (i1,i2,i3,i4,i5), zero(T))

Base.setindex!{T}(A::TSlow{T,0}, v) = (A.data[()] = v)
Base.setindex!{T}(A::TSlow{T,1}, v, i1::Int) = (A.data[(i1,)] = v)
Base.setindex!{T}(A::TSlow{T,2}, v, i1::Int, i2::Int) = (A.data[(i1,i2)] = v)
Base.setindex!{T}(A::TSlow{T,3}, v, i1::Int, i2::Int, i3::Int) =
Base.setindex!(A::TSlow{T,0}, v) where {T} = (A.data[()] = v)
Base.setindex!(A::TSlow{T,1}, v, i1::Int) where {T} = (A.data[(i1,)] = v)
Base.setindex!(A::TSlow{T,2}, v, i1::Int, i2::Int) where {T} = (A.data[(i1,i2)] = v)
Base.setindex!(A::TSlow{T,3}, v, i1::Int, i2::Int, i3::Int) where {T} =
(A.data[(i1,i2,i3)] = v)
Base.setindex!{T}(A::TSlow{T,4}, v, i1::Int, i2::Int, i3::Int, i4::Int) =
Base.setindex!(A::TSlow{T,4}, v, i1::Int, i2::Int, i3::Int, i4::Int) where {T} =
(A.data[(i1,i2,i3,i4)] = v)
Base.setindex!{T}(A::TSlow{T,5}, v, i1::Int, i2::Int, i3::Int, i4::Int, i5::Int) =
Base.setindex!(A::TSlow{T,5}, v, i1::Int, i2::Int, i3::Int, i4::Int, i5::Int) where {T} =
(A.data[(i1,i2,i3,i4,i5)] = v)

const can_inline = Base.JLOptions().can_inline != 0
function test_scalar_indexing{T}(::Type{T}, shape, ::Type{TestAbstractArray})
function test_scalar_indexing(::Type{T}, shape, ::Type{TestAbstractArray}) where T
N = prod(shape)
A = reshape(collect(1:N), shape)
B = T(A)
Expand Down Expand Up @@ -367,7 +367,7 @@ function test_scalar_indexing{T}(::Type{T}, shape, ::Type{TestAbstractArray})
@test A == B
end

function test_vector_indexing{T}(::Type{T}, shape, ::Type{TestAbstractArray})
function test_vector_indexing(::Type{T}, shape, ::Type{TestAbstractArray}) where T
@testset "test_vector_indexing{$(T)}" begin
N = prod(shape)
A = reshape(collect(1:N), shape)
Expand Down Expand Up @@ -410,7 +410,7 @@ function test_vector_indexing{T}(::Type{T}, shape, ::Type{TestAbstractArray})
end
end

function test_primitives{T}(::Type{T}, shape, ::Type{TestAbstractArray})
function test_primitives(::Type{T}, shape, ::Type{TestAbstractArray}) where T
N = prod(shape)
A = reshape(collect(1:N), shape)
B = T(A)
Expand Down Expand Up @@ -481,7 +481,7 @@ Base.IndexStyle(::UnimplementedSlowArray) = Base.IndexCartesian()

mutable struct UnimplementedArray{T, N} <: AbstractArray{T, N} end

function test_getindex_internals{T}(::Type{T}, shape, ::Type{TestAbstractArray})
function test_getindex_internals(::Type{T}, shape, ::Type{TestAbstractArray}) where T
N = prod(shape)
A = reshape(collect(1:N), shape)
B = T(A)
Expand All @@ -501,7 +501,7 @@ function test_getindex_internals(::Type{TestAbstractArray})
@test_throws ErrorException Base.unsafe_getindex(V, 1, 1)
end

function test_setindex!_internals{T}(::Type{T}, shape, ::Type{TestAbstractArray})
function test_setindex!_internals(::Type{T}, shape, ::Type{TestAbstractArray}) where T
N = prod(shape)
A = reshape(collect(1:N), shape)
B = T(A)
Expand Down Expand Up @@ -616,17 +616,17 @@ end
mutable struct TSlowNIndexes{T,N} <: AbstractArray{T,N}
data::Array{T,N}
end
Base.IndexStyle{A<:TSlowNIndexes}(::Type{A}) = Base.IndexCartesian()
Base.IndexStyle(::Type{A}) where {A<:TSlowNIndexes} = Base.IndexCartesian()
Base.size(A::TSlowNIndexes) = size(A.data)
Base.getindex(A::TSlowNIndexes, index::Int...) = error("Must use $(ndims(A)) indexes")
Base.getindex{T}(A::TSlowNIndexes{T,2}, i::Int, j::Int) = A.data[i,j]
Base.getindex(A::TSlowNIndexes{T,2}, i::Int, j::Int) where {T} = A.data[i,j]


mutable struct GenericIterator{N} end
Base.start{N}(::GenericIterator{N}) = 1
Base.next{N}(::GenericIterator{N}, i) = (i, i + 1)
Base.done{N}(::GenericIterator{N}, i) = i > N ? true : false
Base.iteratorsize{N}(::Type{GenericIterator{N}}) = Base.SizeUnknown()
Base.start(::GenericIterator{N}) where {N} = 1
Base.next(::GenericIterator{N}, i) where {N} = (i, i + 1)
Base.done(::GenericIterator{N}, i) where {N} = i > N ? true : false
Base.iteratorsize(::Type{GenericIterator{N}}) where {N} = Base.SizeUnknown()

function test_map(::Type{TestAbstractArray})
empty_pool = WorkerPool([myid()])
Expand Down
14 changes: 7 additions & 7 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1706,16 +1706,16 @@ module RetTypeDecl
struct MeterUnits{T,P} <: Number
val::T
end
MeterUnits{T}(val::T, pow::Int) = MeterUnits{T,pow}(val)
MeterUnits(val::T, pow::Int) where {T} = MeterUnits{T,pow}(val)

m = MeterUnits(1.0, 1) # 1.0 meter, i.e. units of length
m2 = MeterUnits(1.0, 2) # 1.0 meter^2, i.e. units of area

(+){T,pow}(x::MeterUnits{T,pow}, y::MeterUnits{T,pow}) = MeterUnits{T,pow}(x.val+y.val)
(*){T,pow}(x::Int, y::MeterUnits{T,pow}) = MeterUnits{typeof(x*one(T)),pow}(x*y.val)
(*){T}(x::MeterUnits{T,1}, y::MeterUnits{T,1}) = MeterUnits{T,2}(x.val*y.val)
broadcast{T}(::typeof(*), x::MeterUnits{T,1}, y::MeterUnits{T,1}) = MeterUnits{T,2}(x.val*y.val)
convert{T,pow}(::Type{MeterUnits{T,pow}}, y::Real) = MeterUnits{T,pow}(convert(T,y))
(+)(x::MeterUnits{T,pow}, y::MeterUnits{T,pow}) where {T,pow} = MeterUnits{T,pow}(x.val+y.val)
(*)(x::Int, y::MeterUnits{T,pow}) where {T,pow} = MeterUnits{typeof(x*one(T)),pow}(x*y.val)
(*)(x::MeterUnits{T,1}, y::MeterUnits{T,1}) where {T} = MeterUnits{T,2}(x.val*y.val)
broadcast(::typeof(*), x::MeterUnits{T,1}, y::MeterUnits{T,1}) where {T} = MeterUnits{T,2}(x.val*y.val)
convert(::Type{MeterUnits{T,pow}}, y::Real) where {T,pow} = MeterUnits{T,pow}(convert(T,y))

@test @inferred(m+[m,m]) == [m+m,m+m]
@test @inferred([m,m]+m) == [m+m,m+m]
Expand Down Expand Up @@ -1750,7 +1750,7 @@ struct LinSlowMatrix{T} <: DenseArray{T,2}
end

# This is the default, but just to be sure
Base.IndexStyle{A<:LinSlowMatrix}(::Type{A}) = Base.IndexCartesian()
Base.IndexStyle(::Type{A}) where {A<:LinSlowMatrix} = Base.IndexCartesian()

Base.size(A::LinSlowMatrix) = size(A.data)

Expand Down
6 changes: 3 additions & 3 deletions test/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

using Base: findprevnot, findnextnot

tc{N}(r1::NTuple{N,Any}, r2::NTuple{N,Any}) = all(x->tc(x...), [zip(r1,r2)...])
tc{N}(r1::BitArray{N}, r2::Union{BitArray{N},Array{Bool,N}}) = true
tc(r1::NTuple{N,Any}, r2::NTuple{N,Any}) where {N} = all(x->tc(x...), [zip(r1,r2)...])
tc(r1::BitArray{N}, r2::Union{BitArray{N},Array{Bool,N}}) where {N} = true
tc(r1::RowVector{Bool,BitVector}, r2::Union{RowVector{Bool,BitVector},RowVector{Bool,Vector{Bool}}}) = true
tc{T}(r1::T, r2::T) = true
tc(r1::T, r2::T) where {T} = true
tc(r1,r2) = false

bitcheck(b::BitArray) = Base._check_bitarray_consistency(b)
Expand Down
4 changes: 2 additions & 2 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function as_sub(x::AbstractMatrix)
end
y
end
function as_sub{T}(x::AbstractArray{T,3})
function as_sub(x::AbstractArray{T,3}) where T
y = similar(x, eltype(x), tuple(([size(x)...]*2)...))
y = view(y, 2:2:size(y,1), 2:2:size(y,2), 2:2:size(y,3))
for k=1:size(x,3)
Expand Down Expand Up @@ -422,7 +422,7 @@ Base.getindex(A::Array19745, i::Integer...) = A.data[i...]
Base.setindex!(A::Array19745, v::Any, i::Integer...) = setindex!(A.data, v, i...)
Base.size(A::Array19745) = size(A.data)

Base.Broadcast._containertype{T<:Array19745}(::Type{T}) = Array19745
Base.Broadcast._containertype(::Type{T}) where {T<:Array19745} = Array19745

Base.Broadcast.promote_containertype(::Type{Array19745}, ::Type{Array19745}) = Array19745
Base.Broadcast.promote_containertype(::Type{Array19745}, ::Type{Array}) = Array19745
Expand Down
10 changes: 5 additions & 5 deletions test/compile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ try
pool::NominalPool{T, R, NominalValue{T, R}}
end
(::Union{Type{NominalValue}, Type{OrdinalValue}})() = 1
(::Union{Type{NominalValue{T}}, Type{OrdinalValue{T}}}){T}() = 2
(::Type{Vector{NominalValue{T, R}}}){T, R}() = 3
(::Type{Vector{NominalValue{T, T}}}){T}() = 4
(::Union{Type{NominalValue{T}}, Type{OrdinalValue{T}}})() where {T} = 2
(::Type{Vector{NominalValue{T, R}}})() where {T, R} = 3
(::Type{Vector{NominalValue{T, T}}})() where {T} = 4
(::Type{Vector{NominalValue{Int, Int}}})() = 5
# more tests for method signature involving a complicated type
Expand All @@ -125,9 +125,9 @@ try
struct Value18343{T, R}
pool::Pool18343{R, Value18343{T, R}}
end
Base.convert{S}(::Type{Nullable{S}}, ::Value18343{Nullable}) = 2
Base.convert(::Type{Nullable{S}}, ::Value18343{Nullable}) where {S} = 2
Base.convert(::Type{Nullable{Value18343}}, ::Value18343{Nullable}) = 2
Base.convert{T}(::Type{Ref}, ::Value18343{T}) = 3
Base.convert(::Type{Ref}, ::Value18343{T}) where {T} = 3
let some_method = @which Base.include("string")
Expand Down
2 changes: 1 addition & 1 deletion test/dates/periods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ let
Dates.toms(b::Beat) = Dates.value(b) * 86400
Dates._units(b::Beat) = " beat" * (abs(Dates.value(b)) == 1 ? "" : "s")
Base.promote_rule(::Type{Dates.Day}, ::Type{Beat}) = Dates.Millisecond
Base.convert{T<:Dates.Millisecond}(::Type{T}, b::Beat) = T(Dates.toms(b))
Base.convert(::Type{T}, b::Beat) where {T<:Dates.Millisecond} = T(Dates.toms(b))

@test Beat(1000) == Dates.Day(1)
@test Beat(1) < Dates.Day(1)
Expand Down
2 changes: 1 addition & 1 deletion test/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ end
let
local bar
bestkey(d, key) = key
bestkey{K<:AbstractString,V}(d::Associative{K,V}, key) = string(key)
bestkey(d::Associative{K,V}, key) where {K<:AbstractString,V} = string(key)
bar(x) = bestkey(x, :y)
@test bar(Dict(:x => [1,2,5])) == :y
@test bar(Dict("x" => [1,2,5])) == "y"
Expand Down
4 changes: 2 additions & 2 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const K = :K

t(x::AbstractString) = x
t(x::Int, y) = y
t{S <: Integer}(x::S) = x
t(x::S) where {S <: Integer} = x

"t-1"
t(::AbstractString)
Expand Down Expand Up @@ -613,7 +613,7 @@ module I12515
struct EmptyType{T} end

"A new method"
Base.collect{T}(::Type{EmptyType{T}}) = "borked"
Base.collect(::Type{EmptyType{T}}) where {T} = "borked"

end

Expand Down
2 changes: 1 addition & 1 deletion test/intrinsics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ compiled_addf(x, y) = Core.Intrinsics.add_float(x, y)
@test_throws ErrorException compiled_addf(im, im)
@test_throws ErrorException compiled_addf(true, true)

function compiled_conv{T}(::Type{T}, x)
function compiled_conv(::Type{T}, x) where T
t = Core.Intrinsics.trunc_int(T, x)
z = Core.Intrinsics.zext_int(typeof(x), t)
s = Core.Intrinsics.sext_int(typeof(x), t)
Expand Down
2 changes: 1 addition & 1 deletion test/linalg/arnoldi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ size(Phi::CPM) = (size(Phi.kraus,1)^2,size(Phi.kraus,3)^2)
issymmetric(Phi::CPM) = false
ishermitian(Phi::CPM) = false
import Base: A_mul_B!
function A_mul_B!{T<:Base.LinAlg.BlasFloat}(rho2::StridedVector{T},Phi::CPM{T},rho::StridedVector{T})
function A_mul_B!(rho2::StridedVector{T},Phi::CPM{T},rho::StridedVector{T}) where {T<:Base.LinAlg.BlasFloat}
rho = reshape(rho,(size(Phi.kraus,3),size(Phi.kraus,3)))
rho1 = zeros(T,(size(Phi.kraus,1),size(Phi.kraus,1)))
for s = 1:size(Phi.kraus,2)
Expand Down
2 changes: 1 addition & 1 deletion test/linalg/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ end
Quaternion(s::Real, v1::Real, v2::Real, v3::Real) = Quaternion(promote(s, v1, v2, v3)...)
Base.abs2(q::Quaternion) = q.s*q.s + q.v1*q.v1 + q.v2*q.v2 + q.v3*q.v3
Base.abs(q::Quaternion) = sqrt(abs2(q))
Base.real{T}(::Type{Quaternion{T}}) = T
Base.real(::Type{Quaternion{T}}) where {T} = T
Base.conj(q::Quaternion) = Quaternion(q.s, -q.v1, -q.v2, -q.v3)
Base.isfinite(q::Quaternion) = isfinite(q.s) & isfinite(q.v1) & isfinite(q.v2) & isfinite(q.v3)

Expand Down
2 changes: 1 addition & 1 deletion test/linalg/tridiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ for elty in (Float32, Float64, Complex64, Complex128, Int)
end

#Test equivalence of eigenvectors/singular vectors taking into account possible phase (sign) differences
function test_approx_eq_vecs{S<:Real,T<:Real}(a::StridedVecOrMat{S}, b::StridedVecOrMat{T}, error=nothing)
function test_approx_eq_vecs(a::StridedVecOrMat{S}, b::StridedVecOrMat{T}, error=nothing) where {S<:Real,T<:Real}
n = size(a, 1)
@test n==size(b,1) && size(a,2)==size(b,2)
error===nothing && (error=n^3*(eps(S)+eps(T)))
Expand Down
Loading

0 comments on commit c5eae3d

Please sign in to comment.