From 212a4ed63c344cf4102c691fbb3d9beebc4e663a Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 18 Jul 2021 15:57:51 +0200 Subject: [PATCH] don't test implementation details --- python/damask/_crystal.py | 67 ++++++++++++++++++------------------ python/tests/test_Crystal.py | 7 ---- 2 files changed, 34 insertions(+), 40 deletions(-) diff --git a/python/damask/_crystal.py b/python/damask/_crystal.py index 5d3fa24ea..4c9a5cc34 100644 --- a/python/damask/_crystal.py +++ b/python/damask/_crystal.py @@ -60,7 +60,7 @@ class Crystal(): 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}"') if lattice is not None and family is not None and family != lattice_symmetries[lattice]: raise KeyError(f'incompatible family "{family}" for lattice "{lattice}"') @@ -133,7 +133,38 @@ class Crystal(): @property def immutable(self): """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 @@ -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': {} - } + diff --git a/python/tests/test_Crystal.py b/python/tests/test_Crystal.py index 8142e03c5..5481003c9 100644 --- a/python/tests/test_Crystal.py +++ b/python/tests/test_Crystal.py @@ -55,10 +55,3 @@ class TestCrystal: alpha=alpha,beta=beta,gamma=gamma) assert np.allclose(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]