Skip to content

Add Array constructors and convert methods #420

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

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

Conversation

nalimilan
Copy link
Member

Consistent with existing similar methods and the Array constructor, ensure T(::CategoricalArray{U}) and convert(T, ::CategoricalArray{U}) return an Array{U} for T in Array, Vector, Matrix. Same for SubArrays of CategoricalArrays. This avoids creating Array{<:CategoricalValue} objects which are inefficient and unlikely to be what users want.

Apparently we forgot to add these in #123.
Fixes #294.

nalimilan added 2 commits May 1, 2025 15:05
Consistent with existing `similar` methods and the `Array` constructor, ensure
`T(::CategoricalArray{U})` and `convert(T, ::CategoricalArray{U})` return an
`Array{U}` for `T` in `Array`, `Vector`, `Matrix`. Same for `SubArray`s
of `CategoricalArray`s. This avoids creating `Array{<:CategoricalValue}`
objects which are inefficient and unlikely to be what users want.
@nalimilan nalimilan requested review from bkamins and pdeffebach May 1, 2025 13:33
Copy link
Member

@bkamins bkamins left a comment

Choose a reason for hiding this comment

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

This is OK I think, but this is breaking, so it requires some note.

In general I am OK with the policy that we try to store CategoricalValue only in CategoricalArray.

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.

Add Vector conversion
2 participants