Skip to content

Commit

Permalink
Fix _addcounts_radix_sort for empty input array (#706)
Browse files Browse the repository at this point in the history
  • Loading branch information
bosonbaas authored Aug 31, 2021
1 parent ef208fe commit 0a17953
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/counts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ const BaseRadixSortSafeTypes = Union{Int8, Int16, Int32, Int64, Int128,
radixsort_safe(::Type{T}) where T = T<:BaseRadixSortSafeTypes

function _addcounts_radix_sort_loop!(cm::Dict{T}, sx::AbstractArray{T}) where T
isempty(sx) && return cm
last_sx = sx[1]
tmpcount = get(cm, last_sx, 0) + 1

Expand Down
3 changes: 3 additions & 0 deletions test/counts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ cm_any_itr = countmap((i for i in xx))
@test cm_any_itr isa Dict{Any,Int} # no knowledge about type
@test cm_missing == cm

# with empty array
@test countmap(Int[]) == Dict{Int, Int}()

# testing the radixsort-based addcounts
xx = repeat([6, 1, 3, 1], outer=100_000)
cm = Dict{Int, Int}()
Expand Down

0 comments on commit 0a17953

Please sign in to comment.