diff options
author | Robert Kern <robert.kern@gmail.com> | 2006-11-11 12:22:10 +0000 |
---|---|---|
committer | Robert Kern <robert.kern@gmail.com> | 2006-11-11 12:22:10 +0000 |
commit | ad31bbdce9e812e4218839c1446031b9d41dd514 (patch) | |
tree | 8b1af7eacbe7e6358cee2c627ca7dbdf2ab7d5d8 /numpy/lib/function_base.py | |
parent | a3ff1627d8ee99c47e4b3b28d23be434657dca4d (diff) | |
download | numpy-ad31bbdce9e812e4218839c1446031b9d41dd514.tar.gz |
Coerce to floating point arrays in cov to avoid errors when integer arrays are passed.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index a77b696c3..8681bc9b9 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -859,7 +859,7 @@ class vectorize(object): 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 @@ def cov(m,y=None, rowvar=1, bias=0): 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 @@ def cov(m,y=None, rowvar=1, bias=0): 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 @@ def cov(m,y=None, rowvar=1, bias=0): 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 |