Skip to content
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

Don't specialize groupreduce! on result array element type #2335

Merged
merged 2 commits into from
Jul 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/groupeddataframe/splitapplycombine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,8 @@ function copyto_widen!(res::AbstractVector{T}, x::AbstractVector) where T
return res
end

function groupreduce!(res::AbstractVector{U}, f, op, condf, adjust, checkempty::Bool,
incol::AbstractVector{T}, gd::GroupedDataFrame) where {U,T}
function groupreduce!(res::AbstractVector, f, op, condf, adjust, checkempty::Bool,
incol::AbstractVector{T}, gd::GroupedDataFrame) where {T}
n = length(gd)
if adjust !== nothing || checkempty
counts = zeros(Int, n)
Expand All @@ -974,7 +974,7 @@ function groupreduce!(res::AbstractVector{U}, f, op, condf, adjust, checkempty::
x = incol[i]
if gix > 0 && (condf === nothing || condf(x))
# this check should be optimized out if U is not Any
if U === Any && !isassigned(res, gix)
if eltype(res) === Any && !isassigned(res, gix)
res[gix] = f(x, gix)
else
res[gix] = op(res[gix], f(x, gix))
Expand All @@ -985,7 +985,7 @@ function groupreduce!(res::AbstractVector{U}, f, op, condf, adjust, checkempty::
end
end
# handle the case of an unitialized reduction
if U === Any
if eltype(res) === Any
if op === Base.add_sum
initf = zero
elseif op === Base.mul_prod
Expand Down