helpful error message
This commit is contained in:
parent
50d47908fb
commit
f687e0a433
|
@ -1201,9 +1201,12 @@ class Crystal():
|
||||||
|
|
||||||
sep = '-->'
|
sep = '-->'
|
||||||
search = self.lattice+sep+('' if target is None else target.lattice) # type: ignore
|
search = self.lattice+sep+('' if target is None else target.lattice) # type: ignore
|
||||||
m_l,o_l = [transform.split(sep) for transform in orientation_relationships[model].keys() # type: ignore
|
transform = [t for t in orientation_relationships[model].keys() if t.startswith(search)] # type: ignore
|
||||||
if transform.startswith(search)][0]
|
|
||||||
|
|
||||||
|
if len(transform) != 1:
|
||||||
|
raise ValueError(f'invalid target lattice "{search.split(sep)[1]}"')
|
||||||
|
|
||||||
|
m_l,o_l = transform[0].split(sep) # type: ignore
|
||||||
m_p,o_p = orientation_relationships[model][m_l+sep+o_l]
|
m_p,o_p = orientation_relationships[model][m_l+sep+o_l]
|
||||||
other = Crystal(lattice=o_l) if target is None else target
|
other = Crystal(lattice=o_l) if target is None else target
|
||||||
m_p = np.stack((self.to_frame(uvw=m_p[:,0] if len(m_p[0,0])==3 else util.Bravais_to_Miller(uvtw=m_p[:,0])),
|
m_p = np.stack((self.to_frame(uvw=m_p[:,0] if len(m_p[0,0])==3 else util.Bravais_to_Miller(uvtw=m_p[:,0])),
|
||||||
|
|
|
@ -110,3 +110,11 @@ class TestCrystal:
|
||||||
for r in crystal.orientation_relationships:
|
for r in crystal.orientation_relationships:
|
||||||
crystal.relation_operations(r)
|
crystal.relation_operations(r)
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('crystal', [Crystal(lattice='cF'),
|
||||||
|
Crystal(lattice='cI'),
|
||||||
|
Crystal(lattice='hP')])
|
||||||
|
def test_related_invalid_target(self,crystal):
|
||||||
|
relationship = np.random.choice(crystal.orientation_relationships)
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
crystal.relation_operations(relationship,crystal)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue