don't test implementation details

This commit is contained in:
Martin Diehl 2021-07-18 15:57:51 +02:00
parent 2217c3d143
commit 212a4ed63c
2 changed files with 34 additions and 40 deletions

View File

@ -60,7 +60,7 @@ class Crystal():
Angles are given in degrees. Defaults to False. Angles are given in degrees. Defaults to False.
""" """
if family not in [None] + list(self._immutable.keys()): if family not in [None] + list(lattice_symmetries.values()):
raise KeyError(f'invalid crystal family "{family}"') raise KeyError(f'invalid crystal family "{family}"')
if lattice is not None and family is not None and family != lattice_symmetries[lattice]: if lattice is not None and family is not None and family != lattice_symmetries[lattice]:
raise KeyError(f'incompatible family "{family}" for lattice "{lattice}"') raise KeyError(f'incompatible family "{family}" for lattice "{lattice}"')
@ -133,7 +133,38 @@ class Crystal():
@property @property
def immutable(self): def immutable(self):
"""Return immutable lattice parameters.""" """Return immutable lattice parameters."""
return self._immutable[self.family] _immutable = {
'cubic': {
'b': 1.0,
'c': 1.0,
'alpha': np.pi/2.,
'beta': np.pi/2.,
'gamma': np.pi/2.,
},
'hexagonal': {
'b': 1.0,
'alpha': np.pi/2.,
'beta': np.pi/2.,
'gamma': 2.*np.pi/3.,
},
'tetragonal': {
'b': 1.0,
'alpha': np.pi/2.,
'beta': np.pi/2.,
'gamma': np.pi/2.,
},
'orthorhombic': {
'alpha': np.pi/2.,
'beta': np.pi/2.,
'gamma': np.pi/2.,
},
'monoclinic': {
'alpha': np.pi/2.,
'gamma': np.pi/2.,
},
'triclinic': {}
}
return _immutable[self.family]
@property @property
@ -795,34 +826,4 @@ class Crystal():
}, },
} }
_immutable = {
'cubic': {
'b': 1.0,
'c': 1.0,
'alpha': np.pi/2.,
'beta': np.pi/2.,
'gamma': np.pi/2.,
},
'hexagonal': {
'b': 1.0,
'alpha': np.pi/2.,
'beta': np.pi/2.,
'gamma': 2.*np.pi/3.,
},
'tetragonal': {
'b': 1.0,
'alpha': np.pi/2.,
'beta': np.pi/2.,
'gamma': np.pi/2.,
},
'orthorhombic': {
'alpha': np.pi/2.,
'beta': np.pi/2.,
'gamma': np.pi/2.,
},
'monoclinic': {
'alpha': np.pi/2.,
'gamma': np.pi/2.,
},
'triclinic': {}
}

View File

@ -55,10 +55,3 @@ class TestCrystal:
alpha=alpha,beta=beta,gamma=gamma) alpha=alpha,beta=beta,gamma=gamma)
assert np.allclose(vector, assert np.allclose(vector,
c.to_frame(**{keyFrame:c.to_lattice(**{keyLattice:vector})})) c.to_frame(**{keyFrame:c.to_lattice(**{keyLattice:vector})}))
@pytest.mark.parametrize('model',['Bain','KS','GT','GT_prime','NW','Pitsch','Burgers'])
def test_relationship_definition(self,model):
m,o = list(Crystal._orientation_relationships[model])
assert Crystal._orientation_relationships[model][m].shape[:-1] == \
Crystal._orientation_relationships[model][o].shape[:-1]