diff --git a/kwant/tests/test_system.py b/kwant/tests/test_system.py index 3a4034776ee8492221910d0b00dd5a8e1aa97cf1..4ac4783a69f64deca84052c9cd0ee30bb3b13c69 100644 --- a/kwant/tests/test_system.py +++ b/kwant/tests/test_system.py @@ -75,19 +75,15 @@ def test_hamiltonian_submatrix(vectorize): raises(ValueError, kwant.solvers.default.greens_function, syst3, 0.2) # Test for shape errors. - syst[chain2(0), chain(2)] = np.array([[1, 2]]) - syst2 = syst.finalized() - raises(ValueError, syst2.hamiltonian_submatrix) - raises(ValueError, syst2.hamiltonian_submatrix, sparse=True) - syst[chain2(0), chain(2)] = 1 - syst2 = syst.finalized() - raises(ValueError, syst2.hamiltonian_submatrix) - raises(ValueError, syst2.hamiltonian_submatrix, sparse=True) - if vectorize: # non-vectorized systems don't check this at finalization - # Add another hopping of the same type but with a different - # (and still incompatible) shape. - syst[chain2(0), chain(1)] = np.array([[1, 2]]) - raises(ValueError, syst.finalized) + for onsite in ([[1, 2]], 1): + syst[chain2(0), chain(2)] = onsite + if vectorize: + # non-vectorized systems don't check this at finalization + raises(ValueError, syst.finalized) + else: + syst2 = syst.finalized() + raises(ValueError, syst2.hamiltonian_submatrix) + raises(ValueError, syst2.hamiltonian_submatrix, sparse=True) @pytest.mark.parametrize("vectorize", [False, True])