Skip to content

Commit

Permalink
Fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
femtocleaner[bot] committed Aug 22, 2017
1 parent 15ab16f commit 87befa0
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 68 deletions.
74 changes: 37 additions & 37 deletions src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand All @@ -167,65 +167,65 @@ 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))
end
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;
ordered=_isordered(A)) =
$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)


Expand Down Expand Up @@ -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
Expand Down
40 changes: 20 additions & 20 deletions src/nullablearray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand All @@ -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};
Expand Down
10 changes: 5 additions & 5 deletions src/pool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/typedefs.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@compat const DefaultRefType = UInt32
const DefaultRefType = UInt32

## Pools

Expand Down
10 changes: 5 additions & 5 deletions src/value.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand All @@ -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
Expand Down

0 comments on commit 87befa0

Please sign in to comment.