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

Make collect(::CategoricalArray) return a CategoricalArray #252

Merged
merged 1 commit into from
Apr 8, 2020

Conversation

nalimilan
Copy link
Member

This fixes an inconsistency, as currently collect(::Type{<:CategoricalValue}, ::AbstractArray) returns a CategoricalArray but not collect(::CategoricalArray). This is due to the fact that we define similar methods for Array but not for ranges, which is what collect uses internally.

This goes against the collect docstring which says that it returns an Array, but we need to override some similar methods anyway for broadcasting to work (#193). This PR is also needed for NamedArray to return a CategoricalArray from names, as it calls collect(keys(n.dicts[i])) (nalimilan/FreqTables.jl#46). collect seems to be the right abstraction here, but requiring it to return an Array is not appropriate in all situations.

This fixes an inconsistency, as currently `collect(::Type{<:CategoricalValue}, ::AbstractArray)` returns
a `CategoricalArray` but not `collect(::CategoricalArray)`. This is due to the fact that we define
`similar` methods for `Array` but not for ranges, which is what `collect` uses internally.
@nalimilan nalimilan closed this Apr 8, 2020
@nalimilan nalimilan reopened this Apr 8, 2020
@nalimilan nalimilan merged commit 8044adf into master Apr 8, 2020
@nalimilan nalimilan deleted the nl/similar branch April 8, 2020 17:20
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.

1 participant