Skip to content

Commit

Permalink
Merge pull request #36 from jl-spatial/main
Browse files Browse the repository at this point in the history
fix Julia v1.9 @turbo empty iterator error of quickselect!, #35
  • Loading branch information
brenhinkeller authored May 11, 2023
2 parents 9427bd4 + acef764 commit e6b828b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
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"

[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

0 comments on commit e6b828b

Please sign in to comment.