From 798fe1508f28a4ab5b632b8a26bd4f0943736070 Mon Sep 17 00:00:00 2001 From: Joseph Weston <joseph.weston08@gmail.com> Date: Tue, 18 Aug 2015 14:26:33 +0200 Subject: [PATCH] fix test The fact that this test was broken was not seen before because in Python 2 dictionaries have the same sort-order on subsequent program runs. This is not the case for Python 3. --- kwant/tests/test_system.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kwant/tests/test_system.py b/kwant/tests/test_system.py index 346a2dd4..6fa5cd2c 100644 --- a/kwant/tests/test_system.py +++ b/kwant/tests/test_system.py @@ -91,10 +91,10 @@ def test_hamiltonian_submatrix(): sys[((gr(i), gr(i + 1)) for i in xrange(2))] = hopping sys2 = sys.finalized() mat = sys2.hamiltonian_submatrix((2, 1)) - mat_should_be = [[5, 1, 0], [1, 4, 1.], [0, 1, 3]] + mat_should_be = [[3, 1, 0], [1, 4, 1], [0, 1, 5]] # Sorting is required due to unknown compression order of builder. - onsite_hamiltonians = mat.flat[::3] + onsite_hamiltonians = mat.flat[::4] perm = np.argsort(onsite_hamiltonians) mat = mat[perm, :] mat = mat[:, perm] -- GitLab