diff --git a/python/damask/__init__.py b/python/damask/__init__.py index 91ca09b29..a1ccfa3f6 100644 --- a/python/damask/__init__.py +++ b/python/damask/__init__.py @@ -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 diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index c5e853212..05301561f 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -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 \ diff --git a/python/damask/_vtk.py b/python/damask/_vtk.py index 8e6cf490c..2f4d63791 100644 --- a/python/damask/_vtk.py +++ b/python/damask/_vtk.py @@ -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() diff --git a/python/tests/conftest.py b/python/tests/conftest.py index 9410ba15a..719fa8e61 100644 --- a/python/tests/conftest.py +++ b/python/tests/conftest.py @@ -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], diff --git a/python/tests/test_Orientation.py b/python/tests/test_Orientation.py index e0f8a1570..edc5a79d8 100644 --- a/python/tests/test_Orientation.py +++ b/python/tests/test_Orientation.py @@ -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 diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index 8b99f34ec..cc22aba4d 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -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)