Skip to content

Commit

Permalink
Use levels from DataAPI (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
nalimilan committed Oct 4, 2019
1 parent 13dfc1c commit 451f37b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[compat]
julia = "1"
Missings = ">= 0.4.2"
DataAPI = "1.1"
Missings = ">= 0.4.3"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
2 changes: 1 addition & 1 deletion src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ leveltype(::Type{T}) where {T <: CategoricalArray} = leveltype(catvaluetype(T))
Return the levels of categorical array `A`. This may include levels which do not actually appear
in the data (see [`droplevels!`](@ref)).
"""
Missings.levels(A::CategoricalArray) = levels(A.pool)
DataAPI.levels(A::CategoricalArray) = levels(A.pool)

"""
levels!(A::CategoricalArray, newlevels::Vector; allow_missing::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 @@ -280,7 +280,7 @@ function levels!(pool::CategoricalPool{S, R}, newlevels::Vector) where {S, R}
end

index(pool::CategoricalPool) = pool.index
Missings.levels(pool::CategoricalPool) = pool.levels
DataAPI.levels(pool::CategoricalPool) = pool.levels
order(pool::CategoricalPool) = pool.order

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

Missings.levels(sa::SubArray{T,N,P}) where {T,N,P<:CategoricalArray} = levels(parent(sa))
DataAPI.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))
# This method cannot support allow_missing=true since that would modify the parent
levels!(sa::SubArray{T,N,P}, newlevels::Vector) where {T,N,P<:CategoricalArray} =
Expand Down

0 comments on commit 451f37b

Please sign in to comment.