# [Numpy-svn] r3433 - trunk/numpy/lib

numpy-svn at scipy.org numpy-svn at scipy.org
Sat Nov 11 06:22:12 CST 2006

```Author: rkern
Date: 2006-11-11 06:22:10 -0600 (Sat, 11 Nov 2006)
New Revision: 3433

Modified:
trunk/numpy/lib/function_base.py
Log:
Coerce to floating point arrays in cov to avoid errors when integer arrays are passed.

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2006-11-06 21:20:46 UTC (rev 3432)
+++ trunk/numpy/lib/function_base.py	2006-11-11 12:22:10 UTC (rev 3433)
@@ -859,7 +859,7 @@
for x, c in zip(self.ufunc(*args), self.otypes)])
return _res

-def cov(m,y=None, rowvar=1, bias=0):
+def cov(m, y=None, rowvar=1, bias=0):
"""Estimate the covariance matrix.

If m is a vector, return the variance.  For matrices return the
@@ -876,7 +876,7 @@
is a variable and the observations are in the rows.
"""

-    X = array(m,ndmin=2)
+    X = array(m, ndmin=2, dtype=float)
if X.shape[0] == 1:
rowvar = 1
if rowvar:
@@ -888,7 +888,7 @@

if y is not None:
-        y = array(y,copy=False,ndmin=2)
+        y = array(y, copy=False, ndmin=2, dtype=float)
X = concatenate((X,y),axis)

X -= X.mean(axis=1-axis)[tup]
@@ -903,9 +903,9 @@
fact = N-1.0

if not rowvar:
-        return (dot(X.transpose(), X.conj()) / fact).squeeze()
+        return (dot(X.T, X.conj()) / fact).squeeze()
else:
-        return (dot(X,X.transpose().conj())/fact).squeeze()
+        return (dot(X, X.T.conj()) / fact).squeeze()

def corrcoef(x, y=None, rowvar=1, bias=0):
"""The correlation coefficients

```