[Numpy-svn] r6100 - in trunk/numpy/core: . tests

numpy-svn at scipy.org numpy-svn at scipy.org
Mon Nov 24 14:12:10 EST 2008


Author: pierregm
Date: 2008-11-24 13:12:05 -0600 (Mon, 24 Nov 2008)
New Revision: 6100

Modified:
   trunk/numpy/core/defmatrix.py
   trunk/numpy/core/tests/test_defmatrix.py
Log:
* added ddof to np.matrix.var (bug fix #861)

Modified: trunk/numpy/core/defmatrix.py
===================================================================
--- trunk/numpy/core/defmatrix.py	2008-11-24 00:55:10 UTC (rev 6099)
+++ trunk/numpy/core/defmatrix.py	2008-11-24 19:12:05 UTC (rev 6100)
@@ -480,7 +480,7 @@
         is taken before squaring, so that the result is always real
         and nonnegative.
         """
-        return N.ndarray.var(self, axis, dtype, out)._align(axis)
+        return N.ndarray.var(self, axis, dtype, out, ddof)._align(axis)
 
     def prod(self, axis=None, dtype=None, out=None):
         return N.ndarray.prod(self, axis, dtype, out)._align(axis)

Modified: trunk/numpy/core/tests/test_defmatrix.py
===================================================================
--- trunk/numpy/core/tests/test_defmatrix.py	2008-11-24 00:55:10 UTC (rev 6099)
+++ trunk/numpy/core/tests/test_defmatrix.py	2008-11-24 19:12:05 UTC (rev 6100)
@@ -92,6 +92,12 @@
         assert all(x.ptp(0) == array([2, 2]))
         assert all(x.ptp(1) == array([1, 1]))
 
+    def test_var(self):
+        x = np.arange(9).reshape((3,3))
+        mx = x.view(np.matrix)
+        assert_equal(x.var(ddof=0), mx.var(ddof=0))
+        assert_equal(x.var(ddof=1), mx.var(ddof=1))
+
     def test_basic(self):
         import numpy.linalg as linalg
 




More information about the Numpy-svn mailing list