Skip to content
Snippets Groups Projects
Commit 9245b5b9 authored by Anton Akhmerov's avatar Anton Akhmerov Committed by Christoph Groth
Browse files

detect a faulty TranslationalSymmetry when it is created

parent 004ee1fc
Branches
Tags
No related merge requests found
......@@ -239,6 +239,9 @@ class TranslationalSymmetry(builder.Symmetry):
msg = "TranslationalSymmetry takes 1d sequences as parameters.\n" \
"See What's new in kwant 0.2 in the documentation."
raise ValueError(msg)
if np.linalg.matrix_rank(periods) < len(periods):
raise ValueError("Translational symmetry periods must be "
"linearly independent")
# A dictionary containing cached data required for applying the
# symmetry to different site groups.
self.site_group_data = {}
......
......@@ -46,8 +46,7 @@ def test_translational_symmetry():
g2 = lattice.make_lattice(np.identity(2))
g3 = lattice.make_lattice(np.identity(3))
sym = ts((0, 0, 4), (0, 5, 0), (0, 0, 2))
assert_raises(ValueError, sym.add_site_group, g3)
assert_raises(ValueError, ts, (0, 0, 4), (0, 5, 0), (0, 0, 2))
sym = ts((3.3, 0))
assert_raises(ValueError, sym.add_site_group, g2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment