From 87befa0199ba78c7dda477b08076b97a7706fa6b Mon Sep 17 00:00:00 2001 From: "femtocleaner[bot]" Date: Tue, 22 Aug 2017 18:19:46 +0000 Subject: [PATCH] Fix deprecations --- src/array.jl | 74 ++++++++++++++++++++++---------------------- src/nullablearray.jl | 40 ++++++++++++------------ src/pool.jl | 10 +++--- src/typedefs.jl | 2 +- src/value.jl | 10 +++--- 5 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/array.jl b/src/array.jl index 5ec86c53..d77c18f3 100644 --- a/src/array.jl +++ b/src/array.jl @@ -123,41 +123,41 @@ for (A, V, M) in ((:CategoricalArray, :CategoricalVector, :CategoricalMatrix), $A(dims::Int...; ordered=false) = $A{String}(dims, ordered=ordered) - @compat (::Type{$A{T, N, R}}){T, N, R}(dims::NTuple{N,Int}; ordered=false) = + (::Type{$A{T, N, R}}){T, N, R}(dims::NTuple{N,Int}; ordered=false) = $A{T, N, R}(zeros(R, dims), CategoricalPool{T, R}(ordered)) - @compat (::Type{$A{T, N}}){T, N}(dims::NTuple{N,Int}; ordered=false) = + (::Type{$A{T, N}}){T, N}(dims::NTuple{N,Int}; ordered=false) = $A{T, N, DefaultRefType}(dims, ordered=ordered) - @compat (::Type{$A{T}}){T, N}(dims::NTuple{N,Int}; ordered=false) = + (::Type{$A{T}}){T, N}(dims::NTuple{N,Int}; ordered=false) = $A{T, N}(dims, ordered=ordered) - @compat (::Type{$A{T, 1}}){T}(m::Int; ordered=false) = + (::Type{$A{T, 1}}){T}(m::Int; ordered=false) = $A{T, 1}((m,), ordered=ordered) - @compat (::Type{$A{T, 2}}){T}(m::Int, n::Int; ordered=false) = + (::Type{$A{T, 2}}){T}(m::Int, n::Int; ordered=false) = $A{T, 2}((m, n), ordered=ordered) - @compat (::Type{$A{T, 1, R}}){T, R}(m::Int; ordered=false) = + (::Type{$A{T, 1, R}}){T, R}(m::Int; ordered=false) = $A{T, 1, R}((m,), ordered=ordered) # R <: Integer is required to prevent default constructor from being called instead @compat (::Type{$A{T, 2, R}}){T, R <: Integer}(m::Int, n::Int; ordered=false) = $A{T, 2, R}((m, n), ordered=ordered) - @compat (::Type{$A{T, 3, R}}){T, R}(m::Int, n::Int, o::Int; ordered=false) = + (::Type{$A{T, 3, R}}){T, R}(m::Int, n::Int, o::Int; ordered=false) = $A{T, 3, R}((m, n, o), ordered=ordered) - @compat (::Type{$A{T}}){T}(m::Int; ordered=false) = + (::Type{$A{T}}){T}(m::Int; ordered=false) = $A{T}((m,), ordered=ordered) - @compat (::Type{$A{T}}){T}(m::Int, n::Int; ordered=false) = + (::Type{$A{T}}){T}(m::Int, n::Int; ordered=false) = $A{T}((m, n), ordered=ordered) - @compat (::Type{$A{T}}){T}(m::Int, n::Int, o::Int; ordered=false) = + (::Type{$A{T}}){T}(m::Int, n::Int, o::Int; ordered=false) = $A{T}((m, n, o), ordered=ordered) - @compat (::Type{$A{CategoricalValue{T, R}, N, R}}){T, N, R}(dims::NTuple{N,Int}; - ordered=false) = + (::Type{$A{CategoricalValue{T, R}, N, R}}){T, N, R}(dims::NTuple{N,Int}; + ordered=false) = $A{T, N, R}(dims, ordered=ordered) - @compat (::Type{$A{CategoricalValue{T}, N, R}}){T, N, R}(dims::NTuple{N,Int}; - ordered=false) = + (::Type{$A{CategoricalValue{T}, N, R}}){T, N, R}(dims::NTuple{N,Int}; + ordered=false) = $A{T, N, R}(dims, ordered=ordered) - @compat (::Type{$A{CategoricalValue{T, R}, N}}){T, N, R}(dims::NTuple{N,Int}; - ordered=false) = + (::Type{$A{CategoricalValue{T, R}, N}}){T, N, R}(dims::NTuple{N,Int}; + ordered=false) = $A{T, N, R}(dims, ordered=ordered) - @compat (::Type{$A{CategoricalValue{T}, N}}){T, N}(dims::NTuple{N,Int}; - ordered=false) = + (::Type{$A{CategoricalValue{T}, N}}){T, N}(dims::NTuple{N,Int}; + ordered=false) = $A{T, N}(dims, ordered=ordered) # @compat (::Type{$A{CategoricalValue, N}}){N}(dims::NTuple{N,Int}; # ordered=false) = @@ -167,17 +167,17 @@ for (A, V, M) in ((:CategoricalArray, :CategoricalVector, :CategoricalMatrix), # $A{String, N}(dims, ordered=ordered) $V(m::Integer; ordered=false) = $A(m, ordered=ordered) - @compat (::Type{$V{T}}){T}(m::Int; ordered=false) = $A{T}((m,), ordered=ordered) + (::Type{$V{T}}){T}(m::Int; ordered=false) = $A{T}((m,), ordered=ordered) $M(m::Int, n::Int; ordered=false) = $A(m, n, ordered=ordered) - @compat (::Type{$M{T}}){T}(m::Int, n::Int; ordered=false) = $A{T}((m, n), ordered=ordered) + (::Type{$M{T}}){T}(m::Int, n::Int; ordered=false) = $A{T}((m, n), ordered=ordered) ## Constructors from arrays # This method is needed to ensure that a copy of the pool is always made # so that ordered!() does not affect the original array - @compat function (::Type{$A{T, N, R}}){S, T, N, Q, R}(A::CatArray{S, N, Q}; ordered=_isordered(A)) + function (::Type{$A{T, N, R}}){S, T, N, Q, R}(A::CatArray{S, N, Q}; ordered=_isordered(A)) res = convert($A{T, N, R}, A) if res.pool === A.pool # convert() only makes a copy when necessary res = $A{T, N, R}(res.refs, deepcopy(res.pool)) @@ -185,7 +185,7 @@ for (A, V, M) in ((:CategoricalArray, :CategoricalVector, :CategoricalMatrix), ordered!(res, ordered) end - @compat (::Type{$A{T, N, R}}){T, N, R}(A::AbstractArray; ordered=_isordered(A)) = + (::Type{$A{T, N, R}}){T, N, R}(A::AbstractArray; ordered=_isordered(A)) = ordered!(convert($A{T, N, R}, A), ordered) @compat (::Type{$A{T, N, R}}){T<:CategoricalValue, N, R}(A::AbstractArray; @@ -193,39 +193,39 @@ for (A, V, M) in ((:CategoricalArray, :CategoricalVector, :CategoricalMatrix), $A{T.parameters[1], N, R}(A, ordered=ordered) # From AbstractArray - @compat (::Type{$A{T, N}}){S, T, N}(A::AbstractArray{S, N}; ordered=_isordered(A)) = + (::Type{$A{T, N}}){S, T, N}(A::AbstractArray{S, N}; ordered=_isordered(A)) = $A{T, N, DefaultRefType}(A, ordered=ordered) - @compat (::Type{$A{T}}){S, T, N}(A::AbstractArray{S, N}; ordered=_isordered(A)) = + (::Type{$A{T}}){S, T, N}(A::AbstractArray{S, N}; ordered=_isordered(A)) = $A{T, N}(A, ordered=ordered) - @compat (::Type{$A}){T, N}(A::AbstractArray{T, N}; ordered=_isordered(A)) = + (::Type{$A}){T, N}(A::AbstractArray{T, N}; ordered=_isordered(A)) = $A{T, N}(A, ordered=ordered) - @compat (::Type{$V{T}}){S, T}(A::AbstractVector{S}; ordered=_isordered(A)) = + (::Type{$V{T}}){S, T}(A::AbstractVector{S}; ordered=_isordered(A)) = $A{T, 1}(A, ordered=ordered) - @compat (::Type{$V}){T}(A::AbstractVector{T}; ordered=_isordered(A)) = + (::Type{$V}){T}(A::AbstractVector{T}; ordered=_isordered(A)) = $A{T, 1}(A, ordered=ordered) - @compat (::Type{$M{T}}){S, T}(A::AbstractMatrix{S}; ordered=_isordered(A)) = + (::Type{$M{T}}){S, T}(A::AbstractMatrix{S}; ordered=_isordered(A)) = $A{T, 2}(A, ordered=ordered) - @compat (::Type{$M}){T}(A::AbstractMatrix{T}; ordered=_isordered(A)) = + (::Type{$M}){T}(A::AbstractMatrix{T}; ordered=_isordered(A)) = $A{T, 2}(A, ordered=ordered) # From CategoricalArray (preserve R) - @compat (::Type{$A{T, N}}){S, T, N, R}(A::CatArray{S, N, R}; ordered=_isordered(A)) = + (::Type{$A{T, N}}){S, T, N, R}(A::CatArray{S, N, R}; ordered=_isordered(A)) = $A{T, N, R}(A, ordered=ordered) - @compat (::Type{$A{T}}){S, T, N, R}(A::CatArray{S, N, R}; ordered=_isordered(A)) = + (::Type{$A{T}}){S, T, N, R}(A::CatArray{S, N, R}; ordered=_isordered(A)) = $A{T, N, R}(A, ordered=ordered) - @compat (::Type{$A}){T, N, R}(A::CatArray{T, N, R}; ordered=_isordered(A)) = + (::Type{$A}){T, N, R}(A::CatArray{T, N, R}; ordered=_isordered(A)) = $A{T, N, R}(A, ordered=ordered) - @compat (::Type{$V{T}}){S, T, R}(A::CatArray{S, 1, R}; ordered=_isordered(A)) = + (::Type{$V{T}}){S, T, R}(A::CatArray{S, 1, R}; ordered=_isordered(A)) = $A{T, 1, R}(A, ordered=ordered) - @compat (::Type{$V}){T, R}(A::CatArray{T, 1, R}; ordered=_isordered(A)) = + (::Type{$V}){T, R}(A::CatArray{T, 1, R}; ordered=_isordered(A)) = $A{T, 1, R}(A, ordered=ordered) - @compat (::Type{$M{T}}){S, T, R}(A::CatArray{S, 2, R}; ordered=_isordered(A)) = + (::Type{$M{T}}){S, T, R}(A::CatArray{S, 2, R}; ordered=_isordered(A)) = $A{T, 2, R}(A, ordered=ordered) - @compat (::Type{$M}){T, R}(A::CatArray{T, 2, R}; ordered=_isordered(A)) = + (::Type{$M}){T, R}(A::CatArray{T, 2, R}; ordered=_isordered(A)) = $A{T, 2, R}(A, ordered=ordered) @@ -293,7 +293,7 @@ for (A, V, M) in ((:CategoricalArray, :CategoricalVector, :CategoricalMatrix), end end -function @compat(Base.:(==))(A::CatArray, B::CatArray) +function Base.:(==)(A::CatArray, B::CatArray) if size(A) != size(B) return false end diff --git a/src/nullablearray.jl b/src/nullablearray.jl index 4def28a1..682ff0cd 100644 --- a/src/nullablearray.jl +++ b/src/nullablearray.jl @@ -9,33 +9,33 @@ NullableCategoricalArray{T, N}(::Type{Nullable{T}}, dims::NTuple{N,Int}; ordered NullableCategoricalArray{T}(::Type{Nullable{T}}, dims::Int...; ordered=false) = NullableCategoricalArray(T, dims; ordered=ordered) -@compat (::Type{NullableCategoricalArray{Nullable{T}, N, R}}){T, N, R}(dims::NTuple{N,Int}; - ordered=false) = +(::Type{NullableCategoricalArray{Nullable{T}, N, R}}){T, N, R}(dims::NTuple{N,Int}; + ordered=false) = NullableCategoricalArray(zeros(R, dims), CategoricalPool{T, R}(ordered)) -@compat (::Type{NullableCategoricalArray{Nullable{T}, N}}){T, N}(dims::NTuple{N,Int}; - ordered=false) = +(::Type{NullableCategoricalArray{Nullable{T}, N}}){T, N}(dims::NTuple{N,Int}; + ordered=false) = NullableCategoricalArray{T}(dims; ordered=ordered) -@compat (::Type{NullableCategoricalArray{Nullable{T}}}){T}(m::Int; - ordered=false) = +(::Type{NullableCategoricalArray{Nullable{T}}}){T}(m::Int; + ordered=false) = NullableCategoricalArray{T}((m,); ordered=ordered) -@compat (::Type{NullableCategoricalArray{Nullable{T}}}){T}(m::Int, n::Int; - ordered=false) = +(::Type{NullableCategoricalArray{Nullable{T}}}){T}(m::Int, n::Int; + ordered=false) = NullableCategoricalArray{T}((m, n); ordered=ordered) -@compat (::Type{NullableCategoricalArray{Nullable{T}}}){T}(m::Int, n::Int, o::Int; - ordered=false) = +(::Type{NullableCategoricalArray{Nullable{T}}}){T}(m::Int, n::Int, o::Int; + ordered=false) = NullableCategoricalArray{T}((m, n, o); ordered=ordered) -@compat (::Type{NullableCategoricalArray{Nullable{CategoricalValue{T, R}}, N, R}}){T, N, R}(dims::NTuple{N,Int}; - ordered=false) = +(::Type{NullableCategoricalArray{Nullable{CategoricalValue{T, R}}, N, R}}){T, N, R}(dims::NTuple{N,Int}; + ordered=false) = NullableCategoricalArray{T, N, R}(dims; ordered=ordered) -@compat (::Type{NullableCategoricalArray{Nullable{CategoricalValue{T}}, N, R}}){T, N, R}(dims::NTuple{N,Int}; - ordered=false) = +(::Type{NullableCategoricalArray{Nullable{CategoricalValue{T}}, N, R}}){T, N, R}(dims::NTuple{N,Int}; + ordered=false) = NullableCategoricalArray{T, N, R}(dims; ordered=ordered) -@compat (::Type{NullableCategoricalArray{Nullable{CategoricalValue{T, R}}, N}}){T, N, R}(dims::NTuple{N,Int}; - ordered=false) = +(::Type{NullableCategoricalArray{Nullable{CategoricalValue{T, R}}, N}}){T, N, R}(dims::NTuple{N,Int}; + ordered=false) = NullableCategoricalArray{T, N, R}(dims; ordered=ordered) -@compat (::Type{NullableCategoricalArray{Nullable{CategoricalValue{T}}, N}}){T, N}(dims::NTuple{N,Int}; - ordered=false) = +(::Type{NullableCategoricalArray{Nullable{CategoricalValue{T}}, N}}){T, N}(dims::NTuple{N,Int}; + ordered=false) = NullableCategoricalArray{T, N}(dims; ordered=ordered) # @compat (::Type{NullableCategoricalArray{Nullable{CategoricalValue}, N}}){N}(dims::NTuple{N,Int}; # ordered=false) = @@ -44,9 +44,9 @@ NullableCategoricalArray{T}(::Type{Nullable{T}}, dims::Int...; ordered=false) = # ordered=false) = # NullableCategoricalArray{String, N}(dims; ordered=ordered) -@compat (::Type{NullableCategoricalVector{Nullable{T}}}){T}(m::Int; ordered=false) = +(::Type{NullableCategoricalVector{Nullable{T}}}){T}(m::Int; ordered=false) = NullableCategoricalArray{T}((n,); ordered=ordered) -@compat (::Type{NullableCategoricalMatrix{Nullable{T}}}){T}(m::Int, n::Int; ordered=false) = +(::Type{NullableCategoricalMatrix{Nullable{T}}}){T}(m::Int, n::Int; ordered=false) = NullableCategoricalArray{T}((m, n); ordered=ordered) @compat (::Type{NullableCategoricalArray}){T<:Nullable}(A::AbstractArray{T}; diff --git a/src/pool.jl b/src/pool.jl index ac83e1dc..a9145c12 100644 --- a/src/pool.jl +++ b/src/pool.jl @@ -6,14 +6,14 @@ function CategoricalPool{S, T <: Integer, R <: Integer}(index::Vector{S}, CategoricalPool{S, R, CategoricalValue{S, R}}(index, invindex, order, ordered) end -@compat (::Type{CategoricalPool{T, R}}){T, R}(ordered::Bool=false) = +(::Type{CategoricalPool{T, R}}){T, R}(ordered::Bool=false) = CategoricalPool(T[], Dict{T, R}(), R[], ordered) -@compat (::Type{CategoricalPool{T}}){T}(ordered::Bool=false) = +(::Type{CategoricalPool{T}}){T}(ordered::Bool=false) = CategoricalPool(T[], Dict{T, DefaultRefType}(), DefaultRefType[], ordered) -@compat function (::Type{CategoricalPool{T, R}}){T, R}(index::Vector, - ordered::Bool=false) - invindex = buildinvindex(index, R) +function (::Type{CategoricalPool{T, R}}){T, R}(index::Vector, + ordered::Bool=false) +invindex = buildinvindex(index, R) order = Vector{R}(1:length(index)) CategoricalPool(index, invindex, order, ordered) end diff --git a/src/typedefs.jl b/src/typedefs.jl index bbdd368a..a73f7ade 100644 --- a/src/typedefs.jl +++ b/src/typedefs.jl @@ -1,4 +1,4 @@ -@compat const DefaultRefType = UInt32 +const DefaultRefType = UInt32 ## Pools diff --git a/src/value.jl b/src/value.jl index c32133ea..bd2428bd 100644 --- a/src/value.jl +++ b/src/value.jl @@ -23,7 +23,7 @@ Base.convert(::Type{Any}, x::CategoricalArrays.CategoricalValue) = x Base.convert{S}(::Type{S}, x::CategoricalValue) = convert(S, index(x.pool)[x.level]) function Base.show{T}(io::IO, x::CategoricalValue{T}) - if @compat(get(io, :compact, false)) + if get(io, :compact, false) print(io, repr(index(x.pool)[x.level])) elseif isordered(x.pool) @printf(io, "%s %s (%i/%i)", @@ -46,11 +46,11 @@ end end # To fix ambiguities with Base -@compat Base.:(==)(x::CategoricalValue, y::WeakRef) = index(x.pool)[x.level] == y -@compat Base.:(==)(x::WeakRef, y::CategoricalValue) = y == x +Base.:(==)(x::CategoricalValue, y::WeakRef) = index(x.pool)[x.level] == y +Base.:(==)(x::WeakRef, y::CategoricalValue) = y == x -@compat Base.:(==)(x::CategoricalValue, y::Any) = index(x.pool)[x.level] == y -@compat Base.:(==)(x::Any, y::CategoricalValue) = y == x +Base.:(==)(x::CategoricalValue, y::Any) = index(x.pool)[x.level] == y +Base.:(==)(x::Any, y::CategoricalValue) = y == x @inline function Base.isequal(x::CategoricalValue, y::CategoricalValue) if x.pool === y.pool