Skip to content

Commit

Permalink
Use levels from DataAPI (#108)
Browse files Browse the repository at this point in the history
Keep exporting it for now: if we added a deprecation, it would be triggered even
when people call levels after loading CategoricalArrays or DataFrames.

Depends on JuliaData/DataAPI.jl#12.
  • Loading branch information
nalimilan authored Oct 3, 2019
1 parent 2ee5d07 commit 5553a01
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name = "Missings"
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
version = "0.4.2"
version = "0.4.3"

[deps]
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"

[compat]
julia = "1"
DataAPI = "1.1"

[extras]
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
environment:
matrix:
- julia_version: 0.7
- julia_version: 1.0
- julia_version: 1.2
- julia_version: 1.3
- julia_version: nightly

platform:
Expand Down
24 changes: 3 additions & 21 deletions src/Missings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ else
using Base: nonmissingtype
end

import DataAPI

@deprecate T nonmissingtype false

# vector constructors
Expand Down Expand Up @@ -150,27 +152,7 @@ end
return (v::eltype(itr), s)
end

"""
levels(x)
Return a vector of unique values which occur or could occur in collection `x`,
omitting `missing` even if present. Values are returned in the preferred order
for the collection, with the result of [`sort`](@ref) as a default.
Contrary to [`unique`](@ref), this function may return values which do not
actually occur in the data, and does not preserve their order of appearance in `x`.
"""
function levels(x)
T = nonmissingtype(eltype(x))
levs = convert(AbstractArray{T}, filter!(!ismissing, unique(x)))
if hasmethod(isless, Tuple{T, T})
try
sort!(levs)
catch
end
end
levs
end
const levels = DataAPI.levels

struct PassMissing{F} <: Function
f::F
Expand Down

2 comments on commit 5553a01

@nalimilan
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/4057

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.3 -m "<description of version>" 5553a01563d1f6934e465cfeb5c4526688ffd4c0
git push origin v0.4.3

Please sign in to comment.