From 545a085c9333b076c3c9fc872f0f8e2fd345bd63 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 27 May 2021 18:41:42 +0200 Subject: [PATCH] no need to hide, just add suffix to avoid clash with string argument --- python/damask/__init__.py | 1 + python/damask/_orientation.py | 30 +++++++++++------------ python/damask/{_lattice.py => lattice.py} | 0 python/tests/test_Orientation.py | 4 +-- 4 files changed, 18 insertions(+), 17 deletions(-) rename python/damask/{_lattice.py => lattice.py} (100%) diff --git a/python/damask/__init__.py b/python/damask/__init__.py index 060c5e295..ad46d454f 100644 --- a/python/damask/__init__.py +++ b/python/damask/__init__.py @@ -14,6 +14,7 @@ from . import tensor # noqa from . import mechanics # noqa from . import solver # noqa from . import grid_filters # noqa +from . import lattice # noqa #Modules that contain only one class (of the same name), are prefixed by a '_'. #For example, '_colormap' containsa class called 'Colormap' which is imported as 'damask.Colormap'. from ._rotation import Rotation # noqa diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index 919d9e518..a57ac5d84 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -5,16 +5,16 @@ import numpy as np from . import Rotation from . import util from . import tensor -from . import _lattice +from . import lattice as lattice_ -_crystal_families = ['triclinic', - 'monoclinic', - 'orthorhombic', - 'tetragonal', - 'hexagonal', - 'cubic'] +crystal_families = ['triclinic', + 'monoclinic', + 'orthorhombic', + 'tetragonal', + 'hexagonal', + 'cubic'] -_lattice_symmetries = { +lattice_symmetries = { 'aP': 'triclinic', 'mP': 'monoclinic', @@ -136,8 +136,8 @@ class Orientation(Rotation): self.kinematics = None - if lattice in _lattice_symmetries: - self.family = _lattice_symmetries[lattice] + if lattice in lattice_symmetries: + self.family = lattice_symmetries[lattice] self.lattice = lattice self.a = 1 if a is None else a @@ -177,15 +177,15 @@ class Orientation(Rotation): > np.sum(np.roll([self.alpha,self.beta,self.gamma],r)[1:]) for r in range(3)]): raise ValueError ('Each lattice angle must be less than sum of others') - if self.lattice in _lattice.kinematics: - master = _lattice.kinematics[self.lattice] + if self.lattice in lattice_.kinematics: + master = lattice_.kinematics[self.lattice] self.kinematics = {} for m in master: self.kinematics[m] = {'direction':master[m][:,0:3],'plane':master[m][:,3:6]} \ if master[m].shape[-1] == 6 else \ {'direction':self.Bravais_to_Miller(uvtw=master[m][:,0:4]), 'plane': self.Bravais_to_Miller(hkil=master[m][:,4:8])} - elif lattice in _crystal_families: + elif lattice in crystal_families: self.family = lattice self.lattice = None @@ -669,9 +669,9 @@ class Orientation(Rotation): https://doi.org/10.1016/j.actamat.2004.11.021 """ - if model not in _lattice.relations: + if model not in lattice_.relations: raise KeyError(f'Orientation relationship "{model}" is unknown') - r = _lattice.relations[model] + r = lattice_.relations[model] if self.lattice not in r: raise KeyError(f'Relationship "{model}" not supported for lattice "{self.lattice}"') diff --git a/python/damask/_lattice.py b/python/damask/lattice.py similarity index 100% rename from python/damask/_lattice.py rename to python/damask/lattice.py diff --git a/python/tests/test_Orientation.py b/python/tests/test_Orientation.py index 3c4e5bbff..184976749 100644 --- a/python/tests/test_Orientation.py +++ b/python/tests/test_Orientation.py @@ -7,8 +7,8 @@ from damask import Orientation from damask import Table from damask import util from damask import grid_filters -from damask import _lattice as lattice -from damask._orientation import _crystal_families as crystal_families +from damask import lattice +from damask._orientation import crystal_families @pytest.fixture