Skip to content

Commit e08d360

Browse files
committed
Drop sort_if_needed
1 parent 7f5a722 commit e08d360

File tree

4 files changed

+3
-43
lines changed

4 files changed

+3
-43
lines changed

src/pi0-estimators.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ end
171171

172172
function estimate(pValues::PValues{T}, pi0estimator::LeastSlope) where T <: AbstractFloat
173173
n = length(pValues)
174-
pValues = sort_if_needed(pValues)
174+
pValues = sort(pValues)
175175
s0 = lsl_slope(1, n, pValues)
176176
sx = 0
177177
for i in 2:n
@@ -311,7 +311,7 @@ RightBoundary() = RightBoundary([0.02:0.02:0.1; 0.15:0.05:0.95])
311311

312312
function estimate(pValues::PValues{T}, pi0estimator::RightBoundary) where T <: AbstractFloat
313313
n = length(pValues)
314-
λseq = sort_if_needed(pi0estimator.λseq)
314+
λseq = sort(pi0estimator.λseq)
315315
# make sure we catch p-values equal to 1 despite left closure
316316
# use closed=:left because we have been using >= convention in this package
317317
# note that original paper uses > convention.

src/utils.jl

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
## utility functions ##
22

3-
function sort_if_needed(x; kws...)
4-
if issorted(x; kws...)
5-
return x
6-
else
7-
return sort(x; kws...)
8-
end
9-
end
10-
11-
function sort_if_needed!(x; kws...)
12-
if !issorted(x; kws...)
13-
sort!(x; kws...)
14-
end
15-
end
16-
17-
183
function unsort(x; kws...)
194
y = copy(x)
205
while issorted(y; kws...)

test/test-pi0-estimators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ using StatsBase
7373
# used for comparison and compactness
7474
function lsl_pi0_vec(pValues::AbstractVector{T}) where T <: AbstractFloat
7575
n = length(pValues)
76-
pValues = MultipleTesting.sort_if_needed(pValues)
76+
pValues = MultipleTesting.sort(pValues)
7777
s = (1 .- pValues) ./ (n:-1:1)
7878
d = diff(s) .< 0
7979
idx = something(findfirst(d), 0) + 1

test/test-utils.jl

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,6 @@ using Test
5757
end
5858

5959

60-
@testset "sort_if_needed" begin
61-
62-
x = rand(20)
63-
64-
sort_if_needed = MultipleTesting.sort_if_needed
65-
sort_if_needed! = MultipleTesting.sort_if_needed!
66-
67-
# behaves as standard `sort`
68-
@test sort_if_needed(x) == sort(x)
69-
@test sort_if_needed(sort(x)) == sort(x)
70-
71-
# `sort` keywords work
72-
@test sort_if_needed(x, rev = true) == sort(x, rev = true)
73-
@test sort_if_needed(sort(x, rev = true), rev = true) == sort(x, rev = true)
74-
75-
x = rand(20)
76-
y = copy(x)
77-
sort_if_needed!(y)
78-
@test y == sort(x)
79-
sort_if_needed!(y)
80-
@test y == sort(x)
81-
82-
end
83-
84-
8560
@testset "unsort" begin
8661

8762
n = 20

0 commit comments

Comments
 (0)