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

fix Julia v1.9 @turbo empty iterator error of quickselect!, #35 #36

Merged
merged 4 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
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 Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NaNStatistics"
uuid = "b946abbf-3ea7-4610-9019-9858bfdeaf2d"
authors = ["C. Brenhin Keller"]
version = "0.6.26"
version = "0.6.27"

[deps]
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
Expand All @@ -11,10 +11,10 @@ Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"

[compat]
IfElse = "0.1"
LoopVectorization = "0.12.113"
LoopVectorization = "0.12.159"
PrecompileTools = "1"
Static = "0.2 - 0.8"
julia = "1.8"
Static = "0.8"
julia = "1.8, 1.9"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for future reference, just "1.8" allows everything in the 1.x series greater than 1.8 (since after 1.0, minor version numbers aren't breaking any more)


[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
8 changes: 6 additions & 2 deletions src/Sorting/quicksort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ function quickselect!(A::AbstractArray, iₗ=firstindex(A), iᵤ=lastindex(A), k

# Count up elements that must be moved to upper partition
Nᵤ = 0
@turbo for i = (iₗ+1):iᵤ
Nᵤ += A[i] >= pivot
# @turbo
@inbounds for i = (iₗ+1):iᵤ
if A[i] >= pivot
Nᵤ += 1
end
# Nᵤ += Int(A[i] >= pivot)
end
Nₗ = N - Nᵤ

Expand Down
4 changes: 4 additions & 0 deletions test/testSorting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@
@test nanpctile!(copy(A), 50, dims=(2,3)) == median(A, dims=(2,3))

## ---
# test for n₋ >= 384
zi = collect(1:500)
@test NaNStatistics._nanquantile!(zi, 0.999, 1) == [499.501]
@test nanquantile(1:500, 0.999) ≈ 499.501

@test nanquantile(0:10, 0) == 0
@test nanquantile(0:10, 1/100) ≈ 0.1
Expand Down