Skip to content
Snippets Groups Projects
Commit 4d03b823 authored by Christoph Groth's avatar Christoph Groth
Browse files

improve error message when dimensionality of a symmetry and a lattice do not match

parent 7dc73cf2
No related branches found
Tags v1.0.3
No related merge requests found
......@@ -546,7 +546,15 @@ class TranslationalSymmetry(builder.Symmetry):
raise KeyError('Family already processed, delete it from '
'site_family_data first.')
inv = np.linalg.pinv(fam.prim_vecs)
bravais_periods = np.dot(self.periods, inv)
try:
bravais_periods = np.dot(self.periods, inv)
except ValueError:
fam_space_dim = fam.prim_vecs.shape[1]
if dim == fam_space_dim:
raise
msg = ("{0}-d-embedded lattice is incompatible with "
"{1}-d translational symmetry.")
raise ValueError(msg.format(fam_space_dim, dim))
# Absolute tolerance is correct in the following since we want an error
# relative to the closest integer.
if (not np.allclose(bravais_periods, np.round(bravais_periods),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment