From 9b205b5a27b7775ef990e329749c241a1b598a24 Mon Sep 17 00:00:00 2001 From: Joseph Weston <joseph.weston08@gmail.com> Date: Mon, 20 Nov 2017 12:47:08 +0100 Subject: [PATCH] add test that defines failure modes of HoppingKinds --- kwant/tests/test_builder.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kwant/tests/test_builder.py b/kwant/tests/test_builder.py index bc61f971..84d2e671 100644 --- a/kwant/tests/test_builder.py +++ b/kwant/tests/test_builder.py @@ -1021,6 +1021,21 @@ def test_HoppingKind(): assert len({hk: 0, hk2:1, hk3: 2}) == 2 +def test_invalid_HoppingKind(): + g = kwant.lattice.general(ta.identity(3)) + h = kwant.lattice.general(np.identity(3)[:-1]) # 2D lattice in 3D + + delta = (1, 0, 0) + + # families have incompatible tags + with raises(ValueError): + builder.HoppingKind(delta, g, h) + + # delta is incompatible with tags + with raises(ValueError): + builder.HoppingKind(delta, h) + + def test_ModesLead_and_SelfEnergyLead(): lat = builder.SimpleSiteFamily() hoppings = [builder.HoppingKind((1, 0), lat), -- GitLab