-
Notifications
You must be signed in to change notification settings - Fork 34
fix boolean-as-categorical support #327
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
Conversation
| function StatsAPI.coefnames(C::AbstractContrasts, levels::AbstractVector{Bool}, baseind::Integer) | ||
| not_base = [1:(baseind-1); (baseind+1):length(levels)] | ||
| # broadcasted DataAPI.unwrap converts Vector{Bool} to BitVector | ||
| convert(Vector{Bool}, DataAPI.unwrap.(levels[not_base])) |
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.
I wonder how this compares in terms of performance to something like
Bool[DataAPI.unwrap(level) for (i, level) in pairs(level) if i != baseind]or perhaps
Bool[DataAPI.unwrap(@inbounds levels[i])
for i in Iterators.flatten((firstindex(levels):(baseind - 1),
(baseind + 1):lastindex(levels)))]luv 2 micro-optimize
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.
if this is your performance bottleneck ... 😂
Co-authored-by: Alex Arslan <[email protected]>
|
|
||
| # We need an explicit method for `AbstractVector{Bool}` to avoid an ambiguity | ||
| StatsAPI.coefnames(C::HypothesisCoding, levels::AbstractVector{Bool}, baseind::Int) = | ||
| something(C.labels, DataAPI.unwrap.(levels[1:length(levels) .!= baseind])) |
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.
I wonder whether it's worth using invoke to avoid duplicating the method body?
| something(C.labels, DataAPI.unwrap.(levels[1:length(levels) .!= baseind])) | |
| invoke(coefnames, Tuple{HypothesisCoding,AbstractVector,Int}, C, levels, baseind) |
Probably doesn't really matter.
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.
Hmmm, I'll consider that next time, going with the "no change" lazy and fast option for now 😂
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.
Very reasonable
|
Hmm, is the nightly CI failure related? |
fixes #326