diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2018-03-16 09:43:52 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-16 09:43:52 -0600 |
commit | e19e52e0934690323d666704b850dcab1f8c66bf (patch) | |
tree | eedca96806f0c73cafa3e845475cb4f6e776210c /numpy | |
parent | 01cd5c9d8b8cd4cfc5c7bde066aa5ed4736ed3e9 (diff) | |
parent | 018dfbcaa69d8bcda4d909be11a65a188cf5d1dd (diff) | |
download | python-numpy-e19e52e0934690323d666704b850dcab1f8c66bf.tar.gz python-numpy-e19e52e0934690323d666704b850dcab1f8c66bf.tar.bz2 python-numpy-e19e52e0934690323d666704b850dcab1f8c66bf.zip |
Merge pull request #10666 from dfreese/fix/covcomplex
BUG: fix complex casting error in cov with aweights
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/lib/function_base.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 1eb197c12..9ccbfafa2 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -2302,7 +2302,7 @@ def cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None, else: X_T = (X*w).T c = dot(X, X_T.conj()) - c *= 1. / np.float64(fact) + c *= np.true_divide(1, fact) return c.squeeze() diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 2b1ac1cc0..c28257c6d 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1752,7 +1752,9 @@ class TestCov(object): def test_complex(self): x = np.array([[1, 2, 3], [1j, 2j, 3j]]) - assert_allclose(cov(x), np.array([[1., -1.j], [1.j, 1.]])) + res = np.array([[1., -1.j], [1.j, 1.]]) + assert_allclose(cov(x), res) + assert_allclose(cov(x, aweights=np.ones(3)), res) def test_xy(self): x = np.array([[1, 2, 3]]) |