Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CategoricalArray fixes #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

CategoricalArray fixes #46

wants to merge 2 commits into from

Conversation

nalimilan
Copy link
Owner

Fix mixing CategoricalArray with other kinds of arrays, which failed due to problems with how NamedArrays handles CategoricalArray dimnames: now we always unwrap categorical values when creating dimension names.

Fix the type of the dimnames vector when only CategoricalArrays are passed: before this it was always Union{T, Missing}. Change it to always use the same eltype as the input, which is consistent with other AbstractArrays.

Fixes #45.

Fix mixing CategoricalArray with other kinds of arrays, which failed
due to problems with how NamedArrays handles CategoricalArray dimnames:
now we always unwrap categorical values when creating dimension names.

Fix the type of the dimnames vector when only CategoricalArrays are passed:
before this it was always Union{T, Missing}. Change it to always use the same eltype
as the input, which is consistent with other AbstractArrays.
@nalimilan
Copy link
Owner Author

Actually, unwrapping categorical values may not be a good idea, as that makes it impossible to index the table with CategoricalValue{Int} (other than via Name). I've filed davidavdav/NamedArrays.jl#84 to allow using CategoricalArray names instead.

@nalimilan
Copy link
Owner Author

The last commit reverts the unwrapping of categorical values. Tests will fail until the new NamedArrays release.

@@ -77,15 +81,35 @@ cy = CategoricalArray(y)
tab = @inferred freqtable(cx)
@test tab == [100, 100, 100, 100]
@test names(tab) == [["a", "b", "c", "d"]]
@test names(tab, 1) isa Array{eltype(cx)}
@test_broken names(tab, 1) isa typeof(cx)
Copy link
Owner Author

Choose a reason for hiding this comment

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

This will be fixed by JuliaData/CategoricalArrays.jl#252. In practice it shouldn't make a big difference anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix tests failure
1 participant