-
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
levels!(): enhance performance #360
Conversation
@alyst - please allow if the review of the PR might be possibly delayed a bit. If you do not get any feedback in 10 days please bump and I will review (but @nalimilan is a better person to do this and I am sure he eventually will comment on it). Thank you! |
gentle bump |
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.
Sorry for the delay!
test/12_missingarray.jl
Outdated
# check that x is restored correctly when dropping levels is not allowed | ||
@test_throws ArgumentError levels!(x, ["e", "c"]) | ||
@test x == ["c", "b", "b"] | ||
@test levels(x) == ["e", "a", "b", "c"] | ||
|
||
@test levels!(x, ["e", "c"], allowmissing=true) === x | ||
@test levels(x) == ["e", "c"] | ||
@test x[1] === CategoricalValue(x.pool, 2) | ||
@test x[2] === missing | ||
@test x[3] === missing | ||
@test levels(x) == ["e", "c"] |
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.
Also apply these changes to 11_array.jl.
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.
done. I've addressed your latest review (thanks!) and squashed the commits.
test/11_array.jl
Outdated
@test_throws ArgumentError levels!(x, ["a"]) | ||
# check that x is restored correctly when dropping levels is not allowed | ||
@test x == ["a", "b", "b"] | ||
@test levels(x) == ["b", "a"] | ||
|
||
@test_throws ArgumentError levels!(x, ["e", "b"]) | ||
|
||
@test_throws ArgumentError levels!(x, ["e", "a", "b", "a"]) | ||
# one again check that x is restored correctly when dropping levels is not allowed | ||
@test x == ["a", "b", "b"] | ||
@test levels(x) == ["b", "a"] |
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.
Sorry to be a pain, but there are equivalent lines in 12_missingarray.jl: can you keep them in sync? :-)
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.
No problem :) Done
test levels!() exceptions handling and rollback
Enhance the performance of
levels!()
by avoiding redundant checks for duplicate new levels, levels intersection, recoding etc.These checks become expensive as the number of levels grow.