From c7988d13deca6db6f2a2a8ec6ff3385da98e02a2 Mon Sep 17 00:00:00 2001 From: Warren Weckesser Date: Fri, 23 Aug 2013 10:07:14 -0400 Subject: [PATCH] TST: stats: Added a regression test for stats.wilcoxon. Closes gh-2391. --- scipy/stats/tests/test_morestats.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scipy/stats/tests/test_morestats.py b/scipy/stats/tests/test_morestats.py index 18c9140e20c2..69ec7c276023 100644 --- a/scipy/stats/tests/test_morestats.py +++ b/scipy/stats/tests/test_morestats.py @@ -533,5 +533,25 @@ def test_accuracy_wilcoxon(): assert_allclose(p, 0.7240817, rtol=1e-6) +def test_wilcoxon_tie(): + # Regression test for gh-2391. + # Corresponding R code is: + # > result = wilcox.test(rep(0.1, 10), exact=FALSE, correct=FALSE) + # > result$p.value + # [1] 0.001565402 + # > result = wilcox.test(rep(0.1, 10), exact=FALSE, correct=TRUE) + # > result$p.value + # [1] 0.001904195 + stat, p = stats.wilcoxon([0.1] * 10) + expected_p = 0.001565402 + assert_equal(stat, 0) + assert_allclose(p, expected_p, rtol=1e-6) + + stat, p = stats.wilcoxon([0.1] * 10, correction=True) + expected_p = 0.001904195 + assert_equal(stat, 0) + assert_allclose(p, expected_p, rtol=1e-6) + + if __name__ == "__main__": run_module_suite()