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

length gives wrong answer on Categorical values #61

Open
jariji opened this issue Jun 11, 2023 · 4 comments
Open

length gives wrong answer on Categorical values #61

jariji opened this issue Jun 11, 2023 · 4 comments

Comments

@jariji
Copy link

jariji commented Jun 11, 2023

This should give 3 but it gives 1.

length(RLEVector(CategoricalArray(['a', 'a', 'b']))) # 1
@phaverty
Copy link
Owner

Thank you for this report. I'll try to get a fix and a new version out this weekend.

@phaverty
Copy link
Owner

I see the issue. It seems that CategoricalArray is not an Array and CategoricalVector is not a Vector
CategoricalVector <: Vector # false
So the RleVector constructor thinks it has been given a scalar and makes an RleVector with one thing in it, that CategoricalArray. I think this means that RleVectors can't support CatigoricalArrays without a lot of special-case code. I don't know when I'd have time to make those changes, but I'd be happy to consider a PR.

@jariji
Copy link
Author

jariji commented Jun 19, 2023

Why use Vector in the signatures instead of AbstractVector?

@phaverty
Copy link
Owner

Honestly, I'm pretty sure I did that on purpose, but I can't remember why. (It's been years.) I think there were some AbstractVector subtypes I wanted to exclude. I think it may have been BitVector. My coding time is extremely limited these days. Would you like to try swapping Vector for AbstractVector to see if the tests pass and it works in your project?

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

No branches or pull requests

2 participants