RLEVectors.jl
RLEVectors.jl copied to clipboard
`length` gives wrong answer on Categorical values
This should give 3 but it gives 1.
length(RLEVector(CategoricalArray(['a', 'a', 'b']))) # 1
Thank you for this report. I'll try to get a fix and a new version out this weekend.
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.
Why use Vector
in the signatures instead of AbstractVector
?
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?