[Scipy-svn] r4946 - in trunk/scipy/stats: . tests

scipy-svn@scip... scipy-svn@scip...
Sun Nov 2 23:10:13 CST 2008


Author: ariel.rokem
Date: 2008-11-02 23:09:51 -0600 (Sun, 02 Nov 2008)
New Revision: 4946

Modified:
   trunk/scipy/stats/stats.py
   trunk/scipy/stats/tests/test_stats.py
Log:
Fix #714 + tests



Modified: trunk/scipy/stats/stats.py
===================================================================
--- trunk/scipy/stats/stats.py	2008-11-03 04:55:49 UTC (rev 4945)
+++ trunk/scipy/stats/stats.py	2008-11-03 05:09:51 UTC (rev 4946)
@@ -1005,7 +1005,7 @@
     # behaviour at, for example, discontinuities.
     values = np.sort(a,axis=0)
     if limit:
-        values = values[(limit[0] < a) & (a < limit[1])]
+        values = values[(limit[0] <= values) & (values <= limit[1])]
 
     idx = per /100. * (values.shape[0] - 1)
     if (idx % 1 == 0):

Modified: trunk/scipy/stats/tests/test_stats.py
===================================================================
--- trunk/scipy/stats/tests/test_stats.py	2008-11-03 04:55:49 UTC (rev 4945)
+++ trunk/scipy/stats/tests/test_stats.py	2008-11-03 05:09:51 UTC (rev 4946)
@@ -902,5 +902,12 @@
         assert_array_almost_equal(t, self.T1_2)
         assert_array_almost_equal(p, self.P1_2)
 
+def test_scoreatpercentile():
+        assert_equal(stats.scoreatpercentile(range(10),50),4.5)
+        assert_equal(stats.scoreatpercentile(range(10),50,(2,7)),4.5)
+        assert_equal(stats.scoreatpercentile(range(100),50,(1,8)),4.5)
+        assert_equal(stats.scoreatpercentile(np.array([1, 10 ,100]),50,(10,100)), 55)
+        assert_equal(stats.scoreatpercentile(np.array([1, 10 ,100]),50,(1,10)), 5.5)
+
 if __name__ == "__main__":
     run_module_suite()



More information about the Scipy-svn mailing list