polishing

This commit is contained in:
Martin Diehl 2020-11-23 20:06:34 +01:00
parent cbe8160e13
commit 5ab2847b36
6 changed files with 15 additions and 15 deletions

View File

@ -15,6 +15,7 @@ with open(_Path(__file__).parent/_Path('VERSION')) as _f:
version = _re.sub(r'^v','',_f.readline().strip())
__version__ = version
# make classes directly accessible as damask.Class
from ._environment import Environment as _ # noqa
environment = _()
from . import util # noqa
@ -24,7 +25,6 @@ from . import mechanics # noqa
from . import solver # noqa
from . import grid_filters # noqa
from . import lattice # noqa
# make classes directly accessible as damask.Class
from ._rotation import Rotation # noqa
from ._orientation import Orientation # noqa
from ._table import Table # noqa

View File

@ -851,7 +851,7 @@ class Orientation(Rotation):
... }
"""
if vector.shape[-1] != 3:
if np.array(vector).shape[-1] != 3:
raise ValueError('Input is not a field of three-dimensional vectors.')
vector_ = self.to_SST(vector,proper) if in_SST else \

View File

@ -140,7 +140,7 @@ class VTK:
"""
if not os.path.isfile(fname): # vtk has a strange error handling
raise FileNotFoundError(f'No such file: {fname}')
raise FileNotFoundError(f'no such file: {fname}')
ext = Path(fname).suffix
if ext == '.vtk' or dataset_type is not None:
reader = vtk.vtkGenericDataObjectReader()

View File

@ -82,7 +82,7 @@ def set_of_quaternions():
return qu
n = 1100
n = 600
scatter=1.e-2
specials = np.array([
[1.0, 0.0, 0.0, 0.0],

View File

@ -16,7 +16,7 @@ def reference_dir(reference_dir_base):
@pytest.fixture
def set_of_rodrigues(set_of_quaternions):
return Rotation(set_of_quaternions).as_Rodrigues_vector()[:200]
return Rotation(set_of_quaternions).as_Rodrigues_vector()
class TestOrientation:
@ -275,13 +275,13 @@ class TestOrientation:
@pytest.mark.parametrize('lattice',Orientation.crystal_families)
def test_in_FZ_vectorization(self,set_of_rodrigues,lattice):
result = Orientation.from_Rodrigues_vector(rho=set_of_rodrigues.reshape((50,4,-1)),lattice=lattice).in_FZ.reshape(-1)
result = Orientation.from_Rodrigues_vector(rho=set_of_rodrigues.reshape((-1,4,4)),lattice=lattice).in_FZ.reshape(-1)
for r,rho in zip(result,set_of_rodrigues[:len(result)]):
assert r == Orientation.from_Rodrigues_vector(rho=rho,lattice=lattice).in_FZ
@pytest.mark.parametrize('lattice',Orientation.crystal_families)
def test_in_disorientation_FZ_vectorization(self,set_of_rodrigues,lattice):
result = Orientation.from_Rodrigues_vector(rho=set_of_rodrigues.reshape((50,4,-1)),
result = Orientation.from_Rodrigues_vector(rho=set_of_rodrigues.reshape((-1,4,4)),
lattice=lattice).in_disorientation_FZ.reshape(-1)
for r,rho in zip(result,set_of_rodrigues[:len(result)]):
assert r == Orientation.from_Rodrigues_vector(rho=rho,lattice=lattice).in_disorientation_FZ

View File

@ -862,16 +862,16 @@ class TestRotation:
@pytest.mark.parametrize('function,invalid',[(Rotation.from_quaternion, np.array([-1,0,0,0])),
(Rotation.from_quaternion, np.array([1,1,1,0])),
(Rotation.from_Euler_angles, np.array([1,4,0])),
(Rotation.from_axis_angle, np.array([1,0,0,4])),
(Rotation.from_axis_angle, np.array([1,1,0,1])),
(Rotation.from_matrix, np.random.rand(3,3)),
(Rotation.from_matrix, np.array([[1,1,0],[1,2,0],[0,0,1]])),
(Rotation.from_quaternion, np.array([1,1,1,0])),
(Rotation.from_Euler_angles, np.array([1,4,0])),
(Rotation.from_axis_angle, np.array([1,0,0,4])),
(Rotation.from_axis_angle, np.array([1,1,0,1])),
(Rotation.from_matrix, np.random.rand(3,3)),
(Rotation.from_matrix, np.array([[1,1,0],[1,2,0],[0,0,1]])),
(Rotation.from_Rodrigues_vector, np.array([1,0,0,-1])),
(Rotation.from_Rodrigues_vector, np.array([1,1,0,1])),
(Rotation.from_homochoric, np.array([2,2,2])),
(Rotation.from_cubochoric, np.array([1.1,0,0])) ])
(Rotation.from_homochoric, np.array([2,2,2])),
(Rotation.from_cubochoric, np.array([1.1,0,0])) ])
def test_invalid_value(self,function,invalid):
with pytest.raises(ValueError):
function(invalid)