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

scipy-svn@scip... scipy-svn@scip...
Sun Nov 2 04:11:40 CST 2008


Author: stefan
Date: 2008-11-02 04:11:28 -0600 (Sun, 02 Nov 2008)
New Revision: 4916

Modified:
   trunk/scipy/stats/stats.py
   trunk/scipy/stats/tests/test_stats.py
Log:
Skew and kurtosis should return the same type for 1-D array input.  Closes

Modified: trunk/scipy/stats/stats.py
===================================================================
--- trunk/scipy/stats/stats.py	2008-11-02 09:53:28 UTC (rev 4915)
+++ trunk/scipy/stats/stats.py	2008-11-02 10:11:28 UTC (rev 4916)
@@ -806,6 +806,10 @@
             m4 = np.extract(can_correct, m4)
             nval = 1.0/(n-2)/(n-3)*((n*n-1.0)*m4/m2**2.0-3*(n-1)**2.0)
             np.place(vals, can_correct, nval+3.0)
+
+    if vals.ndim == 0:
+        vals = vals.item() # array scalar
+
     if fisher:
         return vals - 3
     else:

Modified: trunk/scipy/stats/tests/test_stats.py
===================================================================
--- trunk/scipy/stats/tests/test_stats.py	2008-11-02 09:53:28 UTC (rev 4915)
+++ trunk/scipy/stats/tests/test_stats.py	2008-11-02 10:11:28 UTC (rev 4916)
@@ -855,6 +855,9 @@
         y = stats.kurtosis(self.testcase,0,0)
         assert_approx_equal(y,1.64)
 
+    def test_kurtosis_array_scalar(self):
+        assert_equal(type(stats.kurtosis([1,2,3])), float)
+
 class TestThreshold(TestCase):
     def test_basic(self):
         a = [-1,2,3,4,5,-1,-2]



More information about the Scipy-svn mailing list