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

make counting more robust to input datatype #722

Merged
merged 45 commits into from
Jun 8, 2022
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3905f6e
support offset arrays and simplify _addcounts_radix_sort_loop
LilithHafner Oct 2, 2021
8eb5855
add tests and fix more occurances of unsupported offset arrays [ref](…
LilithHafner Oct 7, 2021
84ef887
Apply suggestion from code review
LilithHafner Oct 10, 2021
d82295d
Replace dimension checking with varargs `eachindex`
LilithHafner Oct 10, 2021
a4505b2
Test addcounts! on row vector
LilithHafner Oct 10, 2021
c334d4d
Support multidimensional arrays for :radixsort
LilithHafner Oct 10, 2021
94b3e6c
fix lastindex _addcounts_radix_sort_loop! indexing
LilithHafner Oct 11, 2021
87074b2
organize and extend testing; revert to flattening x when passed weigh…
LilithHafner Oct 11, 2021
aa21bc9
removed todo list
LilithHafner Oct 11, 2021
309586f
Update src/counts.jl
LilithHafner Oct 11, 2021
3b5e01d
test :radixsort multidimensional array
LilithHafner Oct 11, 2021
3384f45
docstrings: homogonize, correct, explain proportionmap, shrink onelin…
LilithHafner Oct 11, 2021
6b81b51
whitespace
LilithHafner Oct 11, 2021
18b70b5
test axes(::Weights)
LilithHafner Oct 12, 2021
7aa2d79
Merge branch 'JuliaStats:master' into fix-offset-array
LilithHafner Oct 14, 2021
93caf72
fix tests
LilithHafner Oct 14, 2021
62c5967
Apply suggestions from code review
LilithHafner Oct 14, 2021
1238a2d
put back dimension-mismatch (add messages)
LilithHafner Oct 23, 2021
c1c09d1
test formatting
LilithHafner Oct 23, 2021
bc20432
better error messages
LilithHafner Oct 23, 2021
cbfd92e
test :dict on reshape as well
LilithHafner Oct 23, 2021
60c0aad
typos (fix tests)
LilithHafner Oct 23, 2021
c72b1aa
fixed typo in tests that stopped a test from running
LilithHafner Oct 23, 2021
e4ca264
conform to nalimilan's style
LilithHafner Oct 23, 2021
00fe408
whitespace
LilithHafner Oct 23, 2021
a470531
rename x -> xv to avoid type instability
LilithHafner Oct 23, 2021
aca38a3
test multidimensional countmap input with vector weights
LilithHafner Oct 23, 2021
168b3ab
docstring remove 'when x is a vector'
LilithHafner Oct 23, 2021
204f89a
sum of weights to proportion of weights in docstrings where applicable
LilithHafner Oct 23, 2021
3f3e657
use nalimilan's word choice
LilithHafner Oct 24, 2021
657c1ec
docstring typo
LilithHafner Oct 24, 2021
2ebf1f3
nalimilan's style preference
LilithHafner Oct 24, 2021
f469f0c
vectorize before sorting in iterator case; remove @boundcheck annotat…
LilithHafner Oct 26, 2021
6cf64d9
skip OffsetArray tests before 1.6
LilithHafner Oct 26, 2021
dc1f7ae
Update src/counts.jl
LilithHafner May 17, 2022
4fd45d9
Apply suggestions from code review
LilithHafner May 17, 2022
d31dcce
Merge branch 'JuliaStats:master' into fix-offset-array
LilithHafner May 17, 2022
0fd1c27
Update src/counts.jl
LilithHafner May 17, 2022
fbdf564
Update src/counts.jl
LilithHafner May 19, 2022
e1fab99
use firstindex instead of 1 for robustness to future type signature e…
Jun 2, 2022
717c795
Switch from SortingAlgorithms to Base's radix sort in Julia 1.9+ (clo…
Jun 6, 2022
ba59cc3
Apply suggestions from code review
LilithHafner Jun 6, 2022
2dfba9f
Fix typo
LilithHafner Jun 6, 2022
8f446ee
Style
LilithHafner Jun 6, 2022
e20e28c
Minor fixes
nalimilan Jun 8, 2022
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
17 changes: 8 additions & 9 deletions src/counts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -337,23 +337,22 @@ radixsort_safe(::Type{T}) where T = T<:BaseRadixSortSafeTypes

function _addcounts_radix_sort_loop!(cm::Dict{T}, sx::AbstractArray{T}) where T
LilithHafner marked this conversation as resolved.
Show resolved Hide resolved
isempty(sx) && return cm
last_sx = sx[1]
tmpcount = get(cm, last_sx, 0) + 1
last_sx = first(sx)
start_i = firstindex(sx)

# now the data is sorted: can just run through and accumulate values before
# adding into the Dict
@inbounds for i in 2:length(sx)
@inbounds for i in start_i+1:lastindex(sx)
LilithHafner marked this conversation as resolved.
Show resolved Hide resolved
sxi = sx[i]
if last_sx == sxi
tmpcount += 1
else
cm[last_sx] = tmpcount
if last_sx != sxi
cm[last_sx] = get(cm, last_sx, 0) + i - start_i
last_sx = sxi
tmpcount = get(cm, last_sx, 0) + 1
start_i = i
end
end

cm[sx[end]] = tmpcount
last_sx = last(sx)
cm[last_sx] = get(cm, last_sx, 0) + length(sx) + 1 - start_i
LilithHafner marked this conversation as resolved.
Show resolved Hide resolved

return cm
end
Expand Down