2019-11-23 17:29:41 +05:30
|
|
|
import os
|
2020-06-30 21:05:52 +05:30
|
|
|
import numpy as np
|
2019-11-23 17:29:41 +05:30
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2020-06-30 21:05:52 +05:30
|
|
|
from damask import Rotation
|
|
|
|
|
2019-11-23 17:29:41 +05:30
|
|
|
def pytest_addoption(parser):
|
|
|
|
parser.addoption("--update",
|
|
|
|
action="store_true",
|
|
|
|
default=False)
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def update(request):
|
2019-11-27 17:49:58 +05:30
|
|
|
"""Store current results as new reference results."""
|
2019-11-23 17:29:41 +05:30
|
|
|
return request.config.getoption("--update")
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def reference_dir_base():
|
2019-11-27 17:49:58 +05:30
|
|
|
"""Directory containing reference results."""
|
2019-12-13 01:01:04 +05:30
|
|
|
return os.path.join(os.path.dirname(__file__),'reference')
|
2020-06-30 21:05:52 +05:30
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def set_of_rotations():
|
|
|
|
"""A set of n random rotations."""
|
|
|
|
n = 1100
|
|
|
|
scatter=1.e-2
|
|
|
|
specials = np.array([
|
|
|
|
[1.0, 0.0, 0.0, 0.0],
|
|
|
|
#----------------------
|
|
|
|
[0.0, 1.0, 0.0, 0.0],
|
|
|
|
[0.0, 0.0, 1.0, 0.0],
|
|
|
|
[0.0, 0.0, 0.0, 1.0],
|
|
|
|
[0.0,-1.0, 0.0, 0.0],
|
|
|
|
[0.0, 0.0,-1.0, 0.0],
|
|
|
|
[0.0, 0.0, 0.0,-1.0],
|
|
|
|
#----------------------
|
|
|
|
[1.0, 1.0, 0.0, 0.0],
|
|
|
|
[1.0, 0.0, 1.0, 0.0],
|
|
|
|
[1.0, 0.0, 0.0, 1.0],
|
|
|
|
[0.0, 1.0, 1.0, 0.0],
|
|
|
|
[0.0, 1.0, 0.0, 1.0],
|
|
|
|
[0.0, 0.0, 1.0, 1.0],
|
|
|
|
#----------------------
|
|
|
|
[1.0,-1.0, 0.0, 0.0],
|
|
|
|
[1.0, 0.0,-1.0, 0.0],
|
|
|
|
[1.0, 0.0, 0.0,-1.0],
|
|
|
|
[0.0, 1.0,-1.0, 0.0],
|
|
|
|
[0.0, 1.0, 0.0,-1.0],
|
|
|
|
[0.0, 0.0, 1.0,-1.0],
|
|
|
|
#----------------------
|
|
|
|
[0.0, 1.0,-1.0, 0.0],
|
|
|
|
[0.0, 1.0, 0.0,-1.0],
|
|
|
|
[0.0, 0.0, 1.0,-1.0],
|
|
|
|
#----------------------
|
|
|
|
[0.0,-1.0,-1.0, 0.0],
|
|
|
|
[0.0,-1.0, 0.0,-1.0],
|
|
|
|
[0.0, 0.0,-1.0,-1.0],
|
|
|
|
#----------------------
|
|
|
|
[1.0, 1.0, 1.0, 0.0],
|
|
|
|
[1.0, 1.0, 0.0, 1.0],
|
|
|
|
[1.0, 0.0, 1.0, 1.0],
|
|
|
|
[1.0,-1.0, 1.0, 0.0],
|
|
|
|
[1.0,-1.0, 0.0, 1.0],
|
|
|
|
[1.0, 0.0,-1.0, 1.0],
|
|
|
|
[1.0, 1.0,-1.0, 0.0],
|
|
|
|
[1.0, 1.0, 0.0,-1.0],
|
|
|
|
[1.0, 0.0, 1.0,-1.0],
|
|
|
|
[1.0,-1.0,-1.0, 0.0],
|
|
|
|
[1.0,-1.0, 0.0,-1.0],
|
|
|
|
[1.0, 0.0,-1.0,-1.0],
|
|
|
|
#----------------------
|
|
|
|
[0.0, 1.0, 1.0, 1.0],
|
|
|
|
[0.0, 1.0,-1.0, 1.0],
|
|
|
|
[0.0, 1.0, 1.0,-1.0],
|
|
|
|
[0.0,-1.0, 1.0, 1.0],
|
|
|
|
[0.0,-1.0,-1.0, 1.0],
|
|
|
|
[0.0,-1.0, 1.0,-1.0],
|
|
|
|
[0.0,-1.0,-1.0,-1.0],
|
|
|
|
#----------------------
|
|
|
|
[1.0, 1.0, 1.0, 1.0],
|
|
|
|
[1.0,-1.0, 1.0, 1.0],
|
|
|
|
[1.0, 1.0,-1.0, 1.0],
|
|
|
|
[1.0, 1.0, 1.0,-1.0],
|
|
|
|
[1.0,-1.0,-1.0, 1.0],
|
|
|
|
[1.0,-1.0, 1.0,-1.0],
|
|
|
|
[1.0, 1.0,-1.0,-1.0],
|
|
|
|
[1.0,-1.0,-1.0,-1.0],
|
|
|
|
])
|
|
|
|
specials /= np.linalg.norm(specials,axis=1).reshape(-1,1)
|
|
|
|
specials_scatter = specials + np.broadcast_to(np.random.rand(4)*scatter,specials.shape)
|
|
|
|
specials_scatter /= np.linalg.norm(specials_scatter,axis=1).reshape(-1,1)
|
|
|
|
specials_scatter[specials_scatter[:,0]<0]*=-1
|
|
|
|
|
|
|
|
return [Rotation.from_quaternion(s) for s in specials] + \
|
|
|
|
[Rotation.from_quaternion(s) for s in specials_scatter] + \
|
|
|
|
[Rotation.from_random() for _ in range(n-len(specials)-len(specials_scatter))]
|