DAMASK_EICMD/python/tests/test_Lattice.py

42 lines
1.5 KiB
Python
Raw Normal View History

import random
import pytest
import numpy as np
from damask import Symmetry
class TestSymmetry:
@pytest.mark.parametrize('invalid_symmetry',['fcc','bcc','hello'])
2020-05-23 00:12:13 +05:30
def test_invalid_symmetry(self,invalid_symmetry):
with pytest.raises(KeyError):
2020-05-25 19:24:22 +05:30
s = Symmetry(invalid_symmetry) # noqa
def test_equal(self):
2020-06-30 16:25:08 +05:30
symmetry = random.choice(Symmetry.crystal_systems)
2020-05-24 12:36:11 +05:30
print(symmetry)
assert Symmetry(symmetry) == Symmetry(symmetry)
def test_not_equal(self):
2020-06-30 16:25:08 +05:30
symmetries = random.sample(Symmetry.crystal_systems,k=2)
assert Symmetry(symmetries[0]) != Symmetry(symmetries[1])
2020-06-30 16:25:08 +05:30
@pytest.mark.parametrize('system',Symmetry.crystal_systems)
def test_inFZ(self,system):
assert Symmetry(system).inFZ(np.zeros(3))
2020-06-30 16:25:08 +05:30
@pytest.mark.parametrize('system',Symmetry.crystal_systems)
def test_inDisorientationSST(self,system):
assert Symmetry(system).inDisorientationSST(np.zeros(3))
2020-06-30 16:25:08 +05:30
@pytest.mark.parametrize('system',Symmetry.crystal_systems)
@pytest.mark.parametrize('proper',[True,False])
2020-06-30 16:25:08 +05:30
def test_inSST(self,system,proper):
assert Symmetry(system).inSST(np.zeros(3),proper)
@pytest.mark.parametrize('function',['inFZ','inDisorientationSST'])
2020-05-23 00:12:13 +05:30
def test_invalid_argument(self,function):
2020-05-25 19:24:22 +05:30
s = Symmetry() # noqa
with pytest.raises(ValueError):
eval('s.{}(np.ones(4))'.format(function))