diff options
author | Julian Taylor <jtaylor.debian@googlemail.com> | 2013-10-25 18:56:59 +0200 |
---|---|---|
committer | Julian Taylor <jtaylor.debian@googlemail.com> | 2013-10-25 19:01:29 +0200 |
commit | e549e69020e3dcec08185695db6f7001a62dc934 (patch) | |
tree | cb7dfef52169207eb8b08c7e1b053cd133f870a0 /numpy/linalg/tests | |
parent | a3e8c12ed88c6db2aa89cfbb7a69fc863e8a40dc (diff) | |
download | numpy-e549e69020e3dcec08185695db6f7001a62dc934.tar.gz |
BUG: fix broken UPLO of eigh in python3
UPLO was cast to bytes and compared to a string which is always false in
python3.
closes gh-3977
Diffstat (limited to 'numpy/linalg/tests')
-rw-r--r-- | numpy/linalg/tests/test_linalg.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py index cc1404bf1..c35e9f4f2 100644 --- a/numpy/linalg/tests/test_linalg.py +++ b/numpy/linalg/tests/test_linalg.py @@ -728,7 +728,7 @@ class TestEigh(HermitianTestCase, HermitianGeneralizedTestCase): assert_allclose(dot_generalized(a, evc2), np.asarray(ev2)[...,None,:] * np.asarray(evc2), - rtol=get_rtol(ev.dtype)) + rtol=get_rtol(ev.dtype), err_msg=repr(a)) def test_types(self): def check(dtype): @@ -739,6 +739,27 @@ class TestEigh(HermitianTestCase, HermitianGeneralizedTestCase): for dtype in [single, double, csingle, cdouble]: yield check, dtype + def test_half_filled(self): + expect = np.array([-0.33333333, -0.33333333, -0.33333333, 0.99999999]) + K = np.array([[ 0. , 0. , 0. , 0. ], + [-0.33333333, 0. , 0. , 0. ], + [ 0.33333333, -0.33333333, 0. , 0. ], + [ 0.33333333, -0.33333333, 0.33333333, 0. ]]) + Kr = np.rot90(K, k=2) + w, V = np.linalg.eigh(K) + assert_allclose(np.sort(w), expect, rtol=get_rtol(K.dtype)) + w, V = np.linalg.eigh(UPLO='L', a=K) + assert_allclose(np.sort(w), expect, rtol=get_rtol(K.dtype)) + w, V = np.linalg.eigh(Kr, 'U') + assert_allclose(np.sort(w), expect, rtol=get_rtol(K.dtype)) + + w = np.linalg.eigvalsh(K) + assert_allclose(np.sort(w), expect, rtol=get_rtol(K.dtype)) + w = np.linalg.eigvalsh(UPLO='L', a=K) + assert_allclose(np.sort(w), expect, rtol=get_rtol(K.dtype)) + w = np.linalg.eigvalsh(Kr, 'U') + assert_allclose(np.sort(w), expect, rtol=get_rtol(K.dtype)) + class _TestNorm(object): |