Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
musm committed Apr 21, 2017
1 parent acf19c9 commit a537847
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 41 deletions.
4 changes: 2 additions & 2 deletions base/dates/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ Base.typemin(::Union{Date, Type{Date}}) = Date(-252522163911150, 1, 1)
Base.typemax(::Union{Time, Type{Time}}) = Time(23, 59, 59, 999, 999, 999)
Base.typemin(::Union{Time, Type{Time}}) = Time(0)
# Date-DateTime promotion, isless, ==
Base.eltype{T<:Period}(::Type{T}) = T
Base.eltype(::Type{T}) where {T<:Period} = T
Base.promote_rule(::Type{Date}, x::Type{DateTime}) = DateTime
Base.isless{T<:TimeType}(x::T, y::T) = isless(value(x), value(y))
Base.isless(x::T, y::T) where {T<:TimeType} = isless(value(x), value(y))
Base.isless(x::TimeType, y::TimeType) = isless(Base.promote_noncircular(x, y)...)
==(x::T, y::T) where {T<:TimeType} = ==(value(x), value(y))
function ==(a::Time, b::Time)
Expand Down
4 changes: 2 additions & 2 deletions base/docs/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ print(io::IO, t::Text) = print(io, t.content)
print(io::IO, t::Text{<:Function}) = t.content(io)
show(io::IO, t::Text) = print(io, t)

==(t1::T, t2::T) where {T<:Union{HTML, Text}} = t1.content == t2.content
hash{T<:Union{HTML, Text}}(t::T, h::UInt) = hash(T, hash(t.content, h))
==(t1::T, t2::T) where {T<:Union{HTML,Text}} = t1.content == t2.content
hash(t::T, h::UInt) where {T<:Union{HTML,Text}} = hash(T, hash(t.content, h))

"""
@text_str -> Docs.Text
Expand Down
2 changes: 1 addition & 1 deletion base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function typename(a::Union)
end
typename(union::UnionAll) = typename(union.body)

convert(::Type{T}, x::Tuple{Any, Vararg{Any}}) where {T<:Tuple{Any,Vararg{Any}}} =
convert(::Type{T}, x::Tuple{Any,Vararg{Any}}) where {T<:Tuple{Any,Vararg{Any}}} =
tuple(convert(tuple_type_head(T),x[1]), convert(tuple_type_tail(T), tail(x))...)
convert(::Type{T}, x::T) where {T<:Tuple{Any,Vararg{Any}}} = x

Expand Down
2 changes: 1 addition & 1 deletion base/int.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const BitUnsigned64T = Union{Type{UInt8}, Type{UInt16}, Type{UInt32}, Type{UInt6

(<)(x::T, y::T) where {T<:BitSigned} = slt_int(x, y)

(-)(x::BitInteger) = neg_int(x)
(-)(x::BitInteger) = neg_int(x)
(-)(x::T, y::T) where {T<:BitInteger} = sub_int(x, y)
(+)(x::T, y::T) where {T<:BitInteger} = add_int(x, y)
(*)(x::T, y::T) where {T<:BitInteger} = mul_int(x, y)
Expand Down
14 changes: 7 additions & 7 deletions base/linalg/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@ end
convert(::Type{Matrix}, A::Bidiagonal{T}) where {T} = convert(Matrix{T}, A)
convert(::Type{Array}, A::Bidiagonal) = convert(Matrix, A)
full(A::Bidiagonal) = convert(Array, A)
promote_rule(::Type{Matrix{T}}, ::Type{Bidiagonal{S}}) where {T,S}=Matrix{promote_type(T,S)}
promote_rule(::Type{Matrix{T}}, ::Type{Bidiagonal{S}}) where {T,S} = Matrix{promote_type(T,S)}

#Converting from Bidiagonal to Tridiagonal
Tridiagonal(M::Bidiagonal{T}) where {T} = convert(Tridiagonal{T}, M)
function convert(::Type{Tridiagonal{T}}, A::Bidiagonal) where T
z = zeros(T, size(A)[1]-1)
A.isupper ? Tridiagonal(z, convert(Vector{T},A.dv), convert(Vector{T},A.ev)) : Tridiagonal(convert(Vector{T},A.ev), convert(Vector{T},A.dv), z)
end
promote_rule(::Type{Tridiagonal{T}}, ::Type{Bidiagonal{S}}) where {T,S}=Tridiagonal{promote_type(T,S)}
promote_rule(::Type{Tridiagonal{T}}, ::Type{Bidiagonal{S}}) where {T,S} = Tridiagonal{promote_type(T,S)}

# No-op for trivial conversion Bidiagonal{T} -> Bidiagonal{T}
convert(::Type{Bidiagonal{T}}, A::Bidiagonal{T}) where {T} = A
Expand Down Expand Up @@ -327,15 +327,15 @@ function diag{T}(M::Bidiagonal{T}, n::Integer=0)
end

function +(A::Bidiagonal, B::Bidiagonal)
if A.isupper==B.isupper
if A.isupper == B.isupper
Bidiagonal(A.dv+B.dv, A.ev+B.ev, A.isupper)
else
Tridiagonal((A.isupper ? (B.ev,A.dv+B.dv,A.ev) : (A.ev,A.dv+B.dv,B.ev))...)
end
end

function -(A::Bidiagonal, B::Bidiagonal)
if A.isupper==B.isupper
if A.isupper == B.isupper
Bidiagonal(A.dv-B.dv, A.ev-B.ev, A.isupper)
else
Tridiagonal((A.isupper ? (-B.ev,A.dv-B.dv,A.ev) : (A.ev,A.dv-B.dv,-B.ev))...)
Expand Down Expand Up @@ -373,11 +373,11 @@ function check_A_mul_B!_sizes(C, A, B)
nA, mA = size(A)
nB, mB = size(B)
nC, mC = size(C)
if !(nA == nC)
if nA != nC
throw(DimensionMismatch("sizes size(A)=$(size(A)) and size(C) = $(size(C)) must match at first entry."))
elseif !(mA == nB)
elseif mA != nB
throw(DimensionMismatch("second entry of size(A)=$(size(A)) and first entry of size(B) = $(size(B)) must match."))
elseif !(mB == mC)
elseif mB != mC
throw(DimensionMismatch("sizes size(B)=$(size(B)) and size(C) = $(size(C)) must match at first second entry."))
end
end
Expand Down
4 changes: 2 additions & 2 deletions base/linalg/lq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ end

## Multiplication by Q
### QB
A_mul_B!(A::LQPackedQ{T}, B::StridedVecOrMat{T}) where {T<:BlasFloat} = LAPACK.ormlq!('L','N',A.factors,A.τ,B)
A_mul_B!(A::LQPackedQ{T}, B::StridedVecOrMat{T}) where {T<:BlasFloat} = LAPACK.ormlq!('L','N',A.factors,A.τ,B)
function (*)(A::LQPackedQ,B::StridedVecOrMat)
TAB = promote_type(eltype(A), eltype(B))
A_mul_B!(convert(AbstractMatrix{TAB}, A), copy_oftype(B, TAB))
end

### QcB
Ac_mul_B!(A::LQPackedQ{T}, B::StridedVecOrMat{T}) where {T<:BlasReal} = LAPACK.ormlq!('L','T',A.factors,A.τ,B)
Ac_mul_B!(A::LQPackedQ{T}, B::StridedVecOrMat{T}) where {T<:BlasReal} = LAPACK.ormlq!('L','T',A.factors,A.τ,B)
Ac_mul_B!(A::LQPackedQ{T}, B::StridedVecOrMat{T}) where {T<:BlasComplex} = LAPACK.ormlq!('L','C',A.factors,A.τ,B)
function Ac_mul_B(A::LQPackedQ, B::StridedVecOrMat)
TAB = promote_type(eltype(A), eltype(B))
Expand Down
8 changes: 4 additions & 4 deletions base/linalg/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ end
vecdot(x::Union{DenseArray{T},StridedVector{T}}, y::Union{DenseArray{T},StridedVector{T}}) where {T<:BlasReal} = BLAS.dot(x, y)
vecdot(x::Union{DenseArray{T},StridedVector{T}}, y::Union{DenseArray{T},StridedVector{T}}) where {T<:BlasComplex} = BLAS.dotc(x, y)

function dot(x::Vector{T}, rx::Union{UnitRange{TI},Range{TI}}, y::Vector{T}, ry::Union{UnitRange{TI},Range{TI}}) where {T<:BlasReal, TI<:Integer}
function dot(x::Vector{T}, rx::Union{UnitRange{TI},Range{TI}}, y::Vector{T}, ry::Union{UnitRange{TI},Range{TI}}) where {T<:BlasReal,TI<:Integer}
if length(rx) != length(ry)
throw(DimensionMismatch("length of rx, $(length(rx)), does not equal length of ry, $(length(ry))"))
end
Expand All @@ -56,7 +56,7 @@ function dot(x::Vector{T}, rx::Union{UnitRange{TI},Range{TI}}, y::Vector{T}, ry:
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(x::Vector{T}, rx::Union{UnitRange{TI},Range{TI}}, y::Vector{T}, ry::Union{UnitRange{TI},Range{TI}}) where {T<:BlasComplex, TI<:Integer}
function dot(x::Vector{T}, rx::Union{UnitRange{TI},Range{TI}}, y::Vector{T}, ry::Union{UnitRange{TI},Range{TI}}) where {T<:BlasComplex,TI<:Integer}
if length(rx) != length(ry)
throw(DimensionMismatch("length of rx, $(length(rx)), does not equal length of ry, $(length(ry))"))
end
Expand Down Expand Up @@ -329,8 +329,8 @@ function herk_wrapper!(C::Union{StridedMatrix{T}, StridedMatrix{Complex{T}}}, tA
end

function gemm_wrapper(tA::Char, tB::Char,
A::StridedVecOrMat{T},
B::StridedVecOrMat{T}) where T<:BlasFloat
A::StridedVecOrMat{T},
B::StridedVecOrMat{T}) where T<:BlasFloat
mA, nA = lapack_size(tA, A)
mB, nB = lapack_size(tB, B)
C = similar(B, T, mA, nB)
Expand Down
8 changes: 4 additions & 4 deletions base/linalg/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ function -(A::UnitUpperTriangular)
end

# copy and scale
function copy!(A::T, B::T) where T<:Union{UpperTriangular, UnitUpperTriangular}
function copy!(A::T, B::T) where T<:Union{UpperTriangular,UnitUpperTriangular}
n = size(B,1)
for j = 1:n
for i = 1:(isa(B, UnitUpperTriangular)?j-1:j)
Expand All @@ -333,7 +333,7 @@ function copy!(A::T, B::T) where T<:Union{UpperTriangular, UnitUpperTriangular}
end
return A
end
function copy!(A::T, B::T) where T<:Union{LowerTriangular, UnitLowerTriangular}
function copy!(A::T, B::T) where T<:Union{LowerTriangular,UnitLowerTriangular}
n = size(B,1)
for j = 1:n
for i = (isa(B, UnitLowerTriangular)?j+1:j):n
Expand All @@ -343,7 +343,7 @@ function copy!(A::T, B::T) where T<:Union{LowerTriangular, UnitLowerTriangular}
return A
end

function scale!(A::UpperTriangular, B::Union{UpperTriangular, UnitUpperTriangular}, c::Number)
function scale!(A::UpperTriangular, B::Union{UpperTriangular,UnitUpperTriangular}, c::Number)
n = checksquare(B)
for j = 1:n
if isa(B, UnitUpperTriangular)
Expand All @@ -355,7 +355,7 @@ function scale!(A::UpperTriangular, B::Union{UpperTriangular, UnitUpperTriangula
end
return A
end
function scale!(A::LowerTriangular, B::Union{LowerTriangular, UnitLowerTriangular}, c::Number)
function scale!(A::LowerTriangular, B::Union{LowerTriangular,UnitLowerTriangular}, c::Number)
n = checksquare(B)
for j = 1:n
if isa(B, UnitLowerTriangular)
Expand Down
6 changes: 3 additions & 3 deletions base/markdown/render/html.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ end
function htmlesc(io::IO, s::Symbol)
htmlesc(io, string(s))
end
function htmlesc(io::IO, xs::Union{AbstractString, Symbol}...)
function htmlesc(io::IO, xs::Union{AbstractString,Symbol}...)
for s in xs
htmlesc(io, s)
end
end
function htmlesc(s::Union{AbstractString, Symbol})
function htmlesc(s::Union{AbstractString,Symbol})
sprint(htmlesc, s)
end

Expand Down Expand Up @@ -139,7 +139,7 @@ function htmlinline(io::IO, code::Code)
end
end

function htmlinline(io::IO, md::Union{Symbol, AbstractString})
function htmlinline(io::IO, md::Union{Symbol,AbstractString})
htmlesc(io, md)
end

Expand Down
6 changes: 3 additions & 3 deletions base/pair.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ first(p::Pair) = p.first
last(p::Pair) = p.second

convert(::Type{Pair{A,B}}, x::Pair{A,B}) where {A,B} = x
function convert(::Type{Pair{A,B}}, x::Pair) where A where B
Pair{A, B}(convert(A, x[1]), convert(B, x[2]))
function convert(::Type{Pair{A,B}}, x::Pair) where {A,B}
Pair{A,B}(convert(A, x[1]), convert(B, x[2]))
end

promote_rule(::Type{Pair{A1, B1}}, ::Type{Pair{A2, B2}}) where {A1, B1, A2, B2} =
promote_rule(::Type{Pair{A1,B1}}, ::Type{Pair{A2,B2}}) where {A1,B1,A2,B2} =
Pair{promote_type(A1, A2), promote_type(B1, B2)}
2 changes: 1 addition & 1 deletion base/promotion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ end
# promote numeric types T and S to typejoin(T,S) if T<:S or S<:T
# for example this makes promote_type(Integer,Real) == Real without
# promoting arbitrary pairs of numeric types to Number.
promote_to_supertype(::Type{T}, ::Type{T}, ::Type{T}) where {T<:Number } = (@_pure_meta; T)
promote_to_supertype(::Type{T}, ::Type{T}, ::Type{T}) where {T<:Number} = (@_pure_meta; T)
promote_to_supertype(::Type{T}, ::Type{S}, ::Type{T}) where {T<:Number,S<:Number} = (@_pure_meta; T)
promote_to_supertype(::Type{T}, ::Type{S}, ::Type{S}) where {T<:Number,S<:Number} = (@_pure_meta; S)
promote_to_supertype(::Type{T}, ::Type{S}, ::Type) where {T<:Number,S<:Number} =
Expand Down
4 changes: 2 additions & 2 deletions base/sparse/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function setindex!(x::SparseVector{Tv,Ti}, v::Tv, i::Ti) where {Tv,Ti<:Integer}
x
end

setindex!(x::SparseVector{Tv,Ti}, v, i::Integer) where {Tv, Ti<:Integer} =
setindex!(x::SparseVector{Tv,Ti}, v, i::Integer) where {Tv,Ti<:Integer} =
setindex!(x, convert(Tv, v), convert(Ti, i))


Expand Down Expand Up @@ -415,7 +415,7 @@ function copy!(A::SparseVector, B::SparseMatrixCSC)
return A
end

copy!(A::SparseMatrixCSC, B::SparseVector{TvB,TiB}) where {TvB, TiB} =
copy!(A::SparseMatrixCSC, B::SparseVector{TvB,TiB}) where {TvB,TiB} =
copy!(A, SparseMatrixCSC{TvB,TiB}(B.n, 1, TiB[1, length(B.nzind)+1], B.nzind, B.nzval))


Expand Down
15 changes: 6 additions & 9 deletions base/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1105,10 +1105,8 @@ end
#
# Raises an error if any columnwise vector norm exceeds err. Otherwise, returns
# nothing.
function test_approx_eq_modphase(
a::StridedVecOrMat{S}, b::StridedVecOrMat{T},
err = length(indices(a,1))^3*(eps(S)+eps(T))
) where {S<:Real,T<:Real}
function test_approx_eq_modphase(a::StridedVecOrMat{S}, b::StridedVecOrMat{T},
err = length(indices(a,1))^3*(eps(S)+eps(T))) where {S<:Real,T<:Real}
@test indices(a,1) == indices(b,1) && indices(a,2) == indices(b,2)
for i in indices(a,2)
v1, v2 = a[:, i], b[:, i]
Expand All @@ -1129,11 +1127,10 @@ elsewhere.
want to set this to `false`. See [`Base.isambiguous`](@ref).
"""
function detect_ambiguities(mods...;
imported::Bool = false,
ambiguous_bottom::Bool = false,
allow_bottom::Union{Bool,Void} = nothing
)
if allow_bottom != nothing
imported::Bool = false,
ambiguous_bottom::Bool = false,
allow_bottom::Union{Bool,Void} = nothing)
if allow_bottom !== nothing
Base.depwarn("the `allow_bottom` keyword to detect_ambiguities has been renamed to `ambiguous_bottom`", :detect_ambiguities)
ambiguous_bottom = allow_bottom
end
Expand Down

0 comments on commit a537847

Please sign in to comment.