Skip to content
This repository has been archived by the owner on Oct 3, 2021. It is now read-only.

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkschumacher committed Jun 13, 2014
1 parent 04dd8b0 commit e354e8e
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 47 deletions.
14 changes: 7 additions & 7 deletions test/benjaminiHochberg.jl
@@ -1,15 +1,15 @@
using Base.Test
using PValueAdjust

newPvalues = benjaminiHochberg([0.05, 0.03, 0.01, 0.5])
newPvalues = padjust([0.05, 0.03, 0.01, 0.5], method = :benjaminiHochberg)
@test_approx_eq newPvalues [0.06666666667, 0.06, 0.04, 0.5]

@test_approx_eq benjaminiHochberg([1, 0.5, 0.1, 0.001, 0.0001, 0.002]) [1.0, 0.6, 0.15, 0.003, 0.0006, 0.004]
@test_approx_eq benjaminiHochberg([0.05, 0.05, 0.05]) [0.05, 0.05, 0.05]
@test_approx_eq padjust([1, 0.5, 0.1, 0.001, 0.0001, 0.002], method = :benjaminiHochberg) [1.0, 0.6, 0.15, 0.003, 0.0006, 0.004]
@test_approx_eq padjust([0.05, 0.05, 0.05], method = :benjaminiHochberg) [0.05, 0.05, 0.05]

@test all(benjaminiHochberg([1,1,1]) .<= 1)
@test all(padjust([1,1,1], method = :benjaminiHochberg) .<= 1)

@test_throws benjaminiHochberg([-1])
@test_throws benjaminiHochberg([2])
@test_throws padjust([-1], method = :benjaminiHochberg)
@test_throws padjust([2], method = :benjaminiHochberg)

@test benjaminiHochberg([0.5]) == [0.5]
@test padjust([0.5], method = :benjaminiHochberg) == [0.5]
14 changes: 7 additions & 7 deletions test/benjaminiYekutieli.jl
@@ -1,14 +1,14 @@
using Base.Test
using PValueAdjust

newPvalues = benjaminiYekutieli([0.05, 0.03, 0.01, 0.5])
newPvalues = padjust([0.05, 0.03, 0.01, 0.5], method = :benjaminiYekutieli)
@test_approx_eq newPvalues [0.13888888888889, 0.125, 0.083333333333, 1]

@test_approx_eq benjaminiYekutieli([1, 0.5, 0.1, 0.001, 0.0001, 0.002]) [1.00000, 1.00000, 0.36750, 0.00735, 0.00147, 0.0098]
@test_approx_eq benjaminiYekutieli([0.05, 0.05, 0.05]) [0.0916666666667, 0.0916666666667, 0.0916666666667]
@test all(benjaminiYekutieli([1.0 ,1.0, 1.0]) .<= 1.0)
@test_approx_eq padjust([1, 0.5, 0.1, 0.001, 0.0001, 0.002], method = :benjaminiYekutieli) [1.00000, 1.00000, 0.36750, 0.00735, 0.00147, 0.0098]
@test_approx_eq padjust([0.05, 0.05, 0.05], method = :benjaminiYekutieli) [0.0916666666667, 0.0916666666667, 0.0916666666667]
@test all(padjust([1.0 ,1.0, 1.0], method = :benjaminiYekutieli) .<= 1.0)

@test_throws benjaminiYekutieli([-1])
@test_throws benjaminiYekutieli([2])
@test_throws padjust([-1], method = :benjaminiYekutieli)
@test_throws padjust([2], method = :benjaminiYekutieli)

@test benjaminiYekutieli([0.5]) == [0.5]
@test padjust([0.5], method = :benjaminiYekutieli) == [0.5]
8 changes: 4 additions & 4 deletions test/bonferroni.jl
Expand Up @@ -2,10 +2,10 @@ using Base.Test
using PValueAdjust

pvalues = [0.05, 0.05, 0.05]
newPvalues = bonferroni(pvalues)
newPvalues = padjust(pvalues, method = :bonferroni)
@test_approx_eq newPvalues pvalues * 3.0

@test all(bonferroni([1,1,1]) .<= 1)
@test all(padjust([1,1,1], method = :bonferroni) .<= 1)

@test_throws bonferroni([-1])
@test_throws bonferroni([2])
@test_throws padjust([-1], method = :bonferroni)
@test_throws padjust([2], method = :bonferroni)
14 changes: 7 additions & 7 deletions test/hochberg.jl
@@ -1,15 +1,15 @@
using Base.Test
using PValueAdjust

newPvalues = hochberg([0.05, 0.03, 0.01, 0.5])
newPvalues = padjust([0.05, 0.03, 0.01, 0.5], method = :hochberg)
@test_approx_eq newPvalues [0.1, 0.09, 0.04, 0.5]

@test_approx_eq hochberg([1, 0.5, 0.1, 0.001, 0.0001, 0.002]) [1e+00, 1e+00, 3e-01, 5e-03, 6e-04, 8e-03]
@test_approx_eq hochberg([0.05, 0.05, 0.05]) [0.05, 0.05, 0.05]
@test_approx_eq padjust([1, 0.5, 0.1, 0.001, 0.0001, 0.002], method = :hochberg) [1e+00, 1e+00, 3e-01, 5e-03, 6e-04, 8e-03]
@test_approx_eq padjust([0.05, 0.05, 0.05], method = :hochberg) [0.05, 0.05, 0.05]

@test all(hochberg([1,1,1]) .<= 1)
@test all(padjust([1,1,1], method = :hochberg) .<= 1)

@test_throws hochberg([-1])
@test_throws hochberg([2])
@test_throws padjust([-1], method = :hochberg)
@test_throws padjust([2], method = :hochberg)

@test hochberg([0.5]) == [0.5]
@test padjust([0.5], method = :hochberg) == [0.5]
14 changes: 7 additions & 7 deletions test/holm.jl
@@ -1,15 +1,15 @@
using Base.Test
using PValueAdjust

newPvalues = holm([0.05, 0.03, 0.01, 0.5])
newPvalues = padjust([0.05, 0.03, 0.01, 0.5], method = :holm)
@test_approx_eq newPvalues [0.1, 0.09, 0.04, 0.5]

@test_approx_eq holm([1, 0.5, 0.1, 0.001, 0.0001, 0.002]) [1e+00, 1e+00, 3e-01, 5e-03, 6e-04, 8e-03]
@test_approx_eq holm([0.05, 0.05, 0.05]) [0.15, 0.15, 0.15]
@test_approx_eq padjust([1, 0.5, 0.1, 0.001, 0.0001, 0.002], method = :holm) [1e+00, 1e+00, 3e-01, 5e-03, 6e-04, 8e-03]
@test_approx_eq padjust([0.05, 0.05, 0.05], method = :holm) [0.15, 0.15, 0.15]

@test all(holm([1,1,1]) .<= 1)
@test all(padjust([1,1,1], method = :holm) .<= 1)

@test_throws holm([-1])
@test_throws holm([2])
@test_throws padjust([-1], method = :holm)
@test_throws padjust([2], method = :holm)

@test holm([0.5]) == [0.5]
@test padjust([0.5], method = :holm) == [0.5]
18 changes: 9 additions & 9 deletions test/hommel.jl
@@ -1,20 +1,20 @@
using Base.Test
using PValueAdjust

newPvalues = hommel([0.05, 0.03, 0.01, 0.5])
newPvalues = padjust([0.05, 0.03, 0.01, 0.5], method = :hommel)
@test_approx_eq newPvalues [0.1, 0.075, 0.04, 0.5]

@test_approx_eq hommel([1, 0.5, 0.1, 0.001, 0.0001, 0.002]) [1e+00, 1e+00, 3e-01, 5e-03, 6e-04, 8e-03]
@test_approx_eq hommel([0.05, 0.05, 0.05]) [0.05, 0.05, 0.05]
@test_approx_eq padjust([1, 0.5, 0.1, 0.001, 0.0001, 0.002], method = :hommel) [1e+00, 1e+00, 3e-01, 5e-03, 6e-04, 8e-03]
@test_approx_eq padjust([0.05, 0.05, 0.05], method = :hommel) [0.05, 0.05, 0.05]

pvalues = [0.9954279, 0.9374397, 0.4426119, 0.7564215, 0.1466431, 0.8993471, 0.9507175, 0.1275631, 0.2441196, 0.3745604]
@test_approx_eq hommel(pvalues) [0.9954279, 0.9954279, 0.9954279, 0.9954279, 0.9954279, 0.9954279, 0.9954279, 0.9954279, 0.9954279, 0.9954279]
@test_approx_eq padjust(pvalues, method = :hommel) [0.9954279, 0.9954279, 0.9954279, 0.9954279, 0.9954279, 0.9954279, 0.9954279, 0.9954279, 0.9954279, 0.9954279]

pvalues = [0.05, 0.003, 0.51, 0.0001, 0.01, 0.0, 0.008]
@test_approx_eq hommel(pvalues) [0.1, 0.015, 0.51, 0.0006, 0.03, 0, 0.024]
@test all(hommel([1,1,1]) .<= 1)
@test_approx_eq padjust(pvalues, method = :hommel) [0.1, 0.015, 0.51, 0.0006, 0.03, 0, 0.024]
@test all(padjust([1,1,1], method = :hommel) .<= 1)

@test_throws hommel([-1])
@test_throws hommel([2])
@test_throws padjust([-1], method = :hommel)
@test_throws padjust([2], method = :hommel)

@test hommel([0.5]) == [0.5]
@test padjust([0.5], method = :hommel) == [0.5]
6 changes: 0 additions & 6 deletions test/padjust.jl
Expand Up @@ -3,12 +3,6 @@ using PValueAdjust

# is there a mocking package?
pValues = [1, 0.5, 0.1, 0.001, 0.0001, 0.002]
@test_approx_eq padjust(pValues, method = :hommel) hommel(pValues)
@test_approx_eq padjust(pValues, method = :hochberg) hochberg(pValues)
@test_approx_eq padjust(pValues, method = :bonferroni) bonferroni(pValues)
@test_approx_eq padjust(pValues, method = :holm) holm(pValues)
@test_approx_eq padjust(pValues, method = :benjaminiHochberg) benjaminiHochberg(pValues)
@test_approx_eq padjust(pValues, method = :benjaminiYekutieli) benjaminiYekutieli(pValues)
@test_approx_eq padjust(pValues, method = :none) pValues
@test_approx_eq padjust(pValues) pValues
@test_throws padjust([], method = :wat)

0 comments on commit e354e8e

Please sign in to comment.