Skip to content

Commit

Permalink
Override Nulls.levels() instead of defining custom function
Browse files Browse the repository at this point in the history
This prevents conflicts with DataArrays.
  • Loading branch information
nalimilan committed Oct 14, 2017
1 parent 16a905b commit 3e03f91
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
julia 0.6
Compat 0.19.0
Nulls 0.1.0
Nulls 0.1.2
2 changes: 1 addition & 1 deletion src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ in the data (see [`droplevels!`](@ref)).
As a special case, `null` is never included in the levels, even if
the array contains missing values.
"""
levels(A::CategoricalArray) = levels(A.pool)
Nulls.levels(A::CategoricalArray) = levels(A.pool)

"""
levels!(A::CategoricalArray, newlevels::Vector; nullok::Bool=false)
Expand Down
2 changes: 1 addition & 1 deletion src/pool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function levels!(pool::CategoricalPool{S, R, V}, newlevels::Vector) where {S, R,
end

index(pool::CategoricalPool) = pool.index
levels(pool::CategoricalPool) = pool.levels
Nulls.levels(pool::CategoricalPool) = pool.levels
order(pool::CategoricalPool) = pool.order

isordered(pool::CategoricalPool) = pool.ordered
Expand Down
7 changes: 2 additions & 5 deletions src/subarray.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# delegate methods for SubArrays to support view

for f in [:levels, :isordered]
@eval begin
$f(sa::SubArray{T,N,P}) where {T,N,P<:CategoricalArray} = $f(parent(sa))
end
end
Nulls.levels(sa::SubArray{T,N,P}) where {T,N,P<:CategoricalArray} = levels(parent(sa))
isordered(sa::SubArray{T,N,P}) where {T,N,P<:CategoricalArray} = isordered(parent(sa))

function unique(sa::SubArray{T,N,P}) where {T,N,P<:CategoricalArray}
A = parent(sa)
Expand Down

0 comments on commit 3e03f91

Please sign in to comment.