-
Notifications
You must be signed in to change notification settings - Fork 35
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
Fix sort with unused levels #273
Conversation
The code did not handle correctly the case when unused levels were present at the front. This seems to have become easier to trigger since the index vs. levels distinction was dropped.
src/array.jl
Outdated
perm = sortperm(view(index, seen), order=ord) | ||
nzcounts = counts[seen] | ||
levs = eltype(v) >: Missing ? [missing; v.pool.valindex] : v.pool.valindex | ||
sortedlevs = sort(Vector(view(levs, seen)), order=ord) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use? sort!(levs[seen], order=ord)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a Vector
to avoid calling ourselves and getting a stack overflow. But yes sort!
should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
levs[seen]
would create a new vector anyway - right? But this is minor I guess so it can stay as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually there's a weird behavior which creates a CategoricalVector
with logical indexing. Need to investigate that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so tricky that I ended up filing a design issue against Base: JuliaLang/julia#36106.
The code did not handle correctly the case when unused levels were present at the front.
This seems to have become easier to trigger since the index vs. levels distinction was dropped.
Fixes #269.