RLEVectors.jl icon indicating copy to clipboard operation
RLEVectors.jl copied to clipboard

`length` gives wrong answer on Categorical values

Open jariji opened this issue 1 year ago • 4 comments

This should give 3 but it gives 1.

length(RLEVector(CategoricalArray(['a', 'a', 'b']))) # 1

jariji avatar Jun 11 '23 06:06 jariji

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

phaverty avatar Jun 15 '23 14:06 phaverty

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.

phaverty avatar Jun 19 '23 21:06 phaverty

Why use Vector in the signatures instead of AbstractVector?

jariji avatar Jun 19 '23 21:06 jariji

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?

phaverty avatar Jun 27 '23 14:06 phaverty