From 5202da13ea4976833d3ca03630595cc89327671e Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 7 Jun 2021 21:49:04 +0200 Subject: [PATCH] better not have a "Lattice" object with "lattice" parameter --- python/damask/__init__.py | 2 +- python/damask/{_lattice.py => _crystal.py} | 2 +- python/damask/_orientation.py | 8 +++--- .../{test_Lattice.py => test_Crystal.py} | 26 +++++++++---------- 4 files changed, 19 insertions(+), 19 deletions(-) rename python/damask/{_lattice.py => _crystal.py} (99%) rename python/tests/{test_Lattice.py => test_Crystal.py} (78%) diff --git a/python/damask/__init__.py b/python/damask/__init__.py index eb333487d..de87444b3 100644 --- a/python/damask/__init__.py +++ b/python/damask/__init__.py @@ -18,7 +18,7 @@ from . import grid_filters # noqa #For example, '_colormap' containsa class called 'Colormap' which is imported as 'damask.Colormap'. from ._rotation import Rotation # noqa from ._lattice_family import LatticeFamily # noqa -from ._lattice import Lattice # noqa +from ._crystal import Crystal # noqa from ._orientation import Orientation # noqa from ._table import Table # noqa from ._vtk import VTK # noqa diff --git a/python/damask/_lattice.py b/python/damask/_crystal.py similarity index 99% rename from python/damask/_lattice.py rename to python/damask/_crystal.py index 51e29c282..9d76bc3ab 100644 --- a/python/damask/_lattice.py +++ b/python/damask/_crystal.py @@ -26,7 +26,7 @@ lattice_symmetries = { } -class Lattice(LatticeFamily): +class Crystal(LatticeFamily): """Lattice.""" def __init__(self,*, diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index c26c0b5f9..fec73c551 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -4,7 +4,7 @@ import copy import numpy as np from . import Rotation -from . import Lattice +from . import Crystal from . import util from . import tensor @@ -55,7 +55,7 @@ _parameter_doc = \ """ -class Orientation(Rotation,Lattice): +class Orientation(Rotation,Crystal): """ Representation of crystallographic orientation as combination of rotation and either crystal family or Bravais lattice. @@ -131,7 +131,7 @@ class Orientation(Rotation,Lattice): """ Rotation.__init__(self,rotation) - Lattice.__init__(self,family=family, lattice=lattice, + Crystal.__init__(self,family=family, lattice=lattice, a=a,b=b,c=c, alpha=alpha,beta=beta,gamma=gamma, degrees=degrees) @@ -831,7 +831,7 @@ class Orientation(Rotation,Lattice): """ lattice,o = self.relation_operations(model) - target = Lattice(lattice=lattice) + target = Crystal(lattice=lattice) o = o.broadcast_to(o.shape+self.shape,mode='right') return Orientation(rotation=o*Rotation(self.quaternion).broadcast_to(o.shape,mode='left'), lattice=lattice, diff --git a/python/tests/test_Lattice.py b/python/tests/test_Crystal.py similarity index 78% rename from python/tests/test_Lattice.py rename to python/tests/test_Crystal.py index 0e820e1ce..8142e03c5 100644 --- a/python/tests/test_Lattice.py +++ b/python/tests/test_Crystal.py @@ -1,19 +1,19 @@ import pytest import numpy as np -from damask import Lattice +from damask import Crystal -class TestLattice: +class TestCrystal: def test_double_to_lattice(self): - L = Lattice(lattice='cF') + c = Crystal(lattice='cF') with pytest.raises(KeyError): - L.to_lattice(direction=np.ones(3),plane=np.ones(3)) + c.to_lattice(direction=np.ones(3),plane=np.ones(3)) def test_double_to_frame(self): - L = Lattice(lattice='cF') + c = Crystal(lattice='cF') with pytest.raises(KeyError): - L.to_frame(uvw=np.ones(3),hkl=np.ones(3)) + c.to_frame(uvw=np.ones(3),hkl=np.ones(3)) @pytest.mark.parametrize('lattice,a,b,c,alpha,beta,gamma', [ @@ -25,10 +25,10 @@ class TestLattice: ('cF',1.0,1.0,None,np.pi/2,np.pi/2,np.pi/2), ]) def test_bases_contraction(self,lattice,a,b,c,alpha,beta,gamma): - L = Lattice(lattice=lattice, + c = Crystal(lattice=lattice, a=a,b=b,c=c, alpha=alpha,beta=beta,gamma=gamma) - assert np.allclose(np.eye(3),np.einsum('ik,jk',L.basis_real,L.basis_reciprocal)) + assert np.allclose(np.eye(3),np.einsum('ik,jk',c.basis_real,c.basis_reciprocal)) @pytest.mark.parametrize('keyFrame,keyLattice',[('uvw','direction'),('hkl','plane'),]) @@ -50,15 +50,15 @@ class TestLattice: ('cF',1.0,1.0,1.0,np.pi/2,np.pi/2,np.pi/2), ]) def test_to_frame_to_lattice(self,lattice,a,b,c,alpha,beta,gamma,vector,keyFrame,keyLattice): - L = Lattice(lattice=lattice, + c = Crystal(lattice=lattice, a=a,b=b,c=c, alpha=alpha,beta=beta,gamma=gamma) assert np.allclose(vector, - L.to_frame(**{keyFrame:L.to_lattice(**{keyLattice: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(Lattice._orientation_relationships[model]) - assert Lattice._orientation_relationships[model][m].shape[:-1] == \ - Lattice._orientation_relationships[model][o].shape[:-1] + m,o = list(Crystal._orientation_relationships[model]) + assert Crystal._orientation_relationships[model][m].shape[:-1] == \ + Crystal._orientation_relationships[model][o].shape[:-1]