[Scipy-svn] r6907 - trunk/scipy/stats/tests

scipy-svn at scipy.org scipy-svn at scipy.org
Thu Nov 18 06:40:53 EST 2010


Author: rgommers
Date: 2010-11-18 05:40:52 -0600 (Thu, 18 Nov 2010)
New Revision: 6907

Modified:
   trunk/scipy/stats/tests/test_stats.py
Log:
TST: clean up fisher_exact test. An unused for-loop was left in.

Modified: trunk/scipy/stats/tests/test_stats.py
===================================================================
--- trunk/scipy/stats/tests/test_stats.py	2010-11-17 20:49:26 UTC (rev 6906)
+++ trunk/scipy/stats/tests/test_stats.py	2010-11-18 11:40:52 UTC (rev 6907)
@@ -416,36 +416,24 @@
     res = fisher_exact([[19000, 80000], [20000, 90000]])[1]
     assert_approx_equal(res, 3.319e-9, significant=1)
 
-    tablelist = ( [[100, 2], [1000, 5]],
-                  [[2, 7], [8, 2]],
-                  [[5, 1], [10, 10]],
-                  [[5, 15], [20, 20]],
-                  [[5, 16], [20, 25]],
-                  [[10, 5], [10, 1]],
-                  [[10, 5], [10, 0]],
-                  [[5,0], [1, 4]],
-                  [[0,5], [1, 4]],
-                  [[5,1], [0, 4]],
-                  [[0, 1], [3, 2]] )
-    for table in tablelist:
-        # results from R
-        #
-        # R defines oddsratio differently (see Notes section of fisher_exact
-        # docstring), so those will not match.  We leave them in anyway, in
-        # case they will be useful later on. We test only the p-value.
-        tablist = [
-            ([[100, 2], [1000, 5]], (2.505583993422285e-001,  1.300759363430016e-001)),
-            ([[2, 7], [8, 2]], (8.586235135736206e-002,  2.301413756522114e-002)),
-            ([[5, 1], [10, 10]], (4.725646047336584e+000,  1.973244147157190e-001)),
-            ([[5, 15], [20, 20]], (3.394396617440852e-001,  9.580440012477637e-002)),
-            ([[5, 16], [20, 25]], (3.960558326183334e-001,  1.725864953812994e-001)),
-            ([[10, 5], [10, 1]], (2.116112781158483e-001,  1.973244147157190e-001)),
-            ([[10, 5], [10, 0]], (0.000000000000000e+000,  6.126482213438734e-002)),
-            ([[5, 0], [1, 4]], (np.inf,  4.761904761904762e-002)),
-            ([[0, 5], [1, 4]], (0.000000000000000e+000,  1.000000000000000e+000)),
-            ([[5, 1], [0, 4]], (np.inf,  4.761904761904758e-002)),
-            ([[0, 1], [3, 2]], (0.000000000000000e+000,  1.000000000000000e+000))
-            ]
+    # results from R
+    #
+    # R defines oddsratio differently (see Notes section of fisher_exact
+    # docstring), so those will not match.  We leave them in anyway, in
+    # case they will be useful later on. We test only the p-value.
+    tablist = [
+        ([[100, 2], [1000, 5]], (2.505583993422285e-001,  1.300759363430016e-001)),
+        ([[2, 7], [8, 2]], (8.586235135736206e-002,  2.301413756522114e-002)),
+        ([[5, 1], [10, 10]], (4.725646047336584e+000,  1.973244147157190e-001)),
+        ([[5, 15], [20, 20]], (3.394396617440852e-001,  9.580440012477637e-002)),
+        ([[5, 16], [20, 25]], (3.960558326183334e-001,  1.725864953812994e-001)),
+        ([[10, 5], [10, 1]], (2.116112781158483e-001,  1.973244147157190e-001)),
+        ([[10, 5], [10, 0]], (0.000000000000000e+000,  6.126482213438734e-002)),
+        ([[5, 0], [1, 4]], (np.inf,  4.761904761904762e-002)),
+        ([[0, 5], [1, 4]], (0.000000000000000e+000,  1.000000000000000e+000)),
+        ([[5, 1], [0, 4]], (np.inf,  4.761904761904758e-002)),
+        ([[0, 1], [3, 2]], (0.000000000000000e+000,  1.000000000000000e+000))
+        ]
     for table, res_r in tablist:
         res = fisher_exact(np.asarray(table))
         np.testing.assert_almost_equal(res[1], res_r[1], decimal=11,




More information about the Scipy-svn mailing list