Skip to content

Commit

Permalink
Merge pull request #18 from brenhinkeller/nanpctile
Browse files Browse the repository at this point in the history
Fix bug in handling of percentiles of all-NaN collections
  • Loading branch information
brenhinkeller authored Apr 1, 2022
2 parents da899b5 + 5b9dcaf commit cded29a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 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.8"
version = "0.6.9"

[deps]
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
Expand Down
2 changes: 1 addition & 1 deletion src/Sorting/nanmedian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ end

# Reduce all the dims!
_nanmedian!(A, ::Tuple{Colon}) = _nanmedian!(A, :)
function _nanmedian!(A::AbstractArray{T}, ::Colon) where T
function _nanmedian!(A::AbstractArray{T}, ::Colon) where {T}
iₗ, iᵤ = firstindex(A), lastindex(A)
A, iₗ, iᵤ = sortnans!(A, iₗ, iᵤ)

Expand Down
2 changes: 1 addition & 1 deletion src/Sorting/nanpctile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ end

# Reduce all the dims!
_nanquantile!(A, q::Real, ::Tuple{Colon}) = _nanquantile!(A, q, :)
function _nanquantile!(A, q::Real, ::Colon)
function _nanquantile!(A::AbstractArray{T}, q::Real, ::Colon) where {T}
iₗ, iᵤ = firstindex(A), lastindex(A)
A, iₗ, iᵤ = sortnans!(A, iₗ, iᵤ)

Expand Down
3 changes: 3 additions & 0 deletions test/testSorting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@

@test nanmedian!(0:10) == 5
@test nanmedian!(1:10) == 5.5
@test nanmedian!(fill(NaN, 10)) === NaN

A = rand(100)
@test nanmedian!(copy(A)) == median(A)
Expand Down Expand Up @@ -110,6 +111,7 @@
@test nanpctile!(0:10, 100) == 10
@test nanpctile!(0:10, 13.582) 1.3582
@test nanpctile!(collect(1:10), 50) == 5.5
@test nanpctile!(fill(NaN, 10), 50) === NaN

A = rand(100)
@test nanpctile!(copy(A), 50) == median(A)
Expand Down Expand Up @@ -144,6 +146,7 @@
@test nanquantile(0:10, 1.) == 10
@test nanquantile(0:10, 0.13582) 1.3582
@test nanquantile(collect(1:10), 0.5) == 5.5
@test nanquantile(fill(NaN,10), 0.5) === NaN

A = rand(100)
@test nanquantile(A, 0.5) == median(A)
Expand Down

4 comments on commit cded29a

@brenhinkeller
Copy link
Owner Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/57788

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.9 -m "<description of version>" cded29a16389148df0bcc6bcc1f81adc674f5125
git push origin v0.6.9

Also, note the warning: Version 0.6.9 skips over 0.6.8
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

@brenhinkeller
Copy link
Owner Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request updated: JuliaRegistries/General/57788

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.9 -m "<description of version>" cded29a16389148df0bcc6bcc1f81adc674f5125
git push origin v0.6.9

Please sign in to comment.