From 9bb06081875ac3f0df58e7ba4f8ca589584a99cb Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 19 Mar 2020 14:40:30 +0100 Subject: [PATCH 1/5] maybe this is the cleaner way --- python/damask/__init__.py | 20 +++++++++---------- .../{environment.py => _environment.py} | 0 python/damask/{geom.py => _geom.py} | 0 python/damask/{result.py => _result.py} | 0 python/damask/{ktv.py => _vtk.py} | 0 5 files changed, 10 insertions(+), 10 deletions(-) rename python/damask/{environment.py => _environment.py} (100%) rename python/damask/{geom.py => _geom.py} (100%) rename python/damask/{result.py => _result.py} (100%) rename python/damask/{ktv.py => _vtk.py} (100%) diff --git a/python/damask/__init__.py b/python/damask/__init__.py index 86f8d4862..7951c63e1 100644 --- a/python/damask/__init__.py +++ b/python/damask/__init__.py @@ -7,16 +7,16 @@ with open(_os.path.join(_os.path.dirname(__file__),'VERSION')) as _f: version = _re.sub(r'^v','',_f.readline().strip()) # classes -from .environment import Environment # noqa -from .table import Table # noqa -from .ktv import VTK # noqa -from .colormaps import Colormap, Color # noqa -from .rotation import Rotation # noqa -from .lattice import Symmetry, Lattice# noqa -from .orientation import Orientation # noqa -from .result import Result # noqa -from .geom import Geom # noqa -from .solver import Solver # noqa +from ._environment import Environment # noqa +from .table import Table # noqa +from ._vtk import VTK # noqa +from .colormaps import Colormap, Color # noqa +from .rotation import Rotation # noqa +from .lattice import Symmetry, Lattice# noqa +from .orientation import Orientation # noqa +from ._result import Result # noqa +from ._geom import Geom # noqa +from .solver import Solver # noqa # deprecated from .asciitable import ASCIItable # noqa diff --git a/python/damask/environment.py b/python/damask/_environment.py similarity index 100% rename from python/damask/environment.py rename to python/damask/_environment.py diff --git a/python/damask/geom.py b/python/damask/_geom.py similarity index 100% rename from python/damask/geom.py rename to python/damask/_geom.py diff --git a/python/damask/result.py b/python/damask/_result.py similarity index 100% rename from python/damask/result.py rename to python/damask/_result.py diff --git a/python/damask/ktv.py b/python/damask/_vtk.py similarity index 100% rename from python/damask/ktv.py rename to python/damask/_vtk.py From 327899890a3cc8302a237df163fa7bedf5f97694 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 19 Mar 2020 15:06:25 +0100 Subject: [PATCH 2/5] this works for internal --- python/damask/{Lambert.py => _Lambert.py} | 0 python/damask/rotation.py | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) rename python/damask/{Lambert.py => _Lambert.py} (100%) diff --git a/python/damask/Lambert.py b/python/damask/_Lambert.py similarity index 100% rename from python/damask/Lambert.py rename to python/damask/_Lambert.py diff --git a/python/damask/rotation.py b/python/damask/rotation.py index 28f55853b..8cb1f139d 100644 --- a/python/damask/rotation.py +++ b/python/damask/rotation.py @@ -1,6 +1,6 @@ import numpy as np -from . import Lambert +from ._Lambert import * P = -1 @@ -802,7 +802,7 @@ class Rotation: @staticmethod def ho2cu(ho): """Homochoric vector to cubochoric vector.""" - return Lambert.BallToCube(ho) + return BallToCube(ho) #---------- Cubochoric ---------- @@ -834,4 +834,4 @@ class Rotation: @staticmethod def cu2ho(cu): """Cubochoric vector to homochoric vector.""" - return Lambert.CubeToBall(cu) + return CubeToBall(cu) From 899cc913c4f8af98770e911ed49eec69d526b1fe Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 19 Mar 2020 15:09:05 +0100 Subject: [PATCH 3/5] python style names --- python/damask/_Lambert.py | 4 ++-- python/damask/rotation.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/python/damask/_Lambert.py b/python/damask/_Lambert.py index 0ff177f9b..3524d3567 100644 --- a/python/damask/_Lambert.py +++ b/python/damask/_Lambert.py @@ -36,7 +36,7 @@ sc = np.pi**(1./6.)/6.**(1./6.) beta = np.pi**(5./6.)/6.**(1./6.)/2. R1 = (3.*np.pi/4.)**(1./3.) -def CubeToBall(cube): +def cube_to_ball(cube): """ Map a point in a uniform refinable cubical grid to a point on a uniform refinable grid on a ball. @@ -87,7 +87,7 @@ def CubeToBall(cube): return ball -def BallToCube(ball): +def ball_to_cube(ball): """ Map a point on a uniform refinable grid on a ball to a point in a uniform refinable cubical grid. diff --git a/python/damask/rotation.py b/python/damask/rotation.py index 8cb1f139d..0b481e149 100644 --- a/python/damask/rotation.py +++ b/python/damask/rotation.py @@ -1,6 +1,6 @@ import numpy as np -from ._Lambert import * +from ._Lambert import ball_to_cube, cube_to_ball P = -1 @@ -802,7 +802,7 @@ class Rotation: @staticmethod def ho2cu(ho): """Homochoric vector to cubochoric vector.""" - return BallToCube(ho) + return ball_to_cube(ho) #---------- Cubochoric ---------- @@ -834,4 +834,4 @@ class Rotation: @staticmethod def cu2ho(cu): """Cubochoric vector to homochoric vector.""" - return CubeToBall(cu) + return cube_to_ball(cu) From e390982be7b1330d08194fadfd169ea5479840d2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 19 Mar 2020 15:19:11 +0100 Subject: [PATCH 4/5] clean first level structure --- python/damask/__init__.py | 18 +++++++++--------- .../damask/{asciitable.py => _asciitable.py} | 0 python/damask/{colormaps.py => _colormaps.py} | 0 python/damask/{config => _config}/__init__.py | 0 python/damask/{config => _config}/material.py | 0 python/damask/{lattice.py => _lattice.py} | 4 +--- .../damask/{orientation.py => _orientation.py} | 4 ++-- python/damask/{rotation.py => _rotation.py} | 0 python/damask/{solver => _solver}/__init__.py | 0 python/damask/{solver => _solver}/marc.py | 0 python/damask/{solver => _solver}/solver.py | 0 python/damask/{table.py => _table.py} | 0 python/damask/{test.py => _test.py} | 0 13 files changed, 12 insertions(+), 14 deletions(-) rename python/damask/{asciitable.py => _asciitable.py} (100%) rename python/damask/{colormaps.py => _colormaps.py} (100%) rename python/damask/{config => _config}/__init__.py (100%) rename python/damask/{config => _config}/material.py (100%) rename python/damask/{lattice.py => _lattice.py} (99%) rename python/damask/{orientation.py => _orientation.py} (99%) rename python/damask/{rotation.py => _rotation.py} (100%) rename python/damask/{solver => _solver}/__init__.py (100%) rename python/damask/{solver => _solver}/marc.py (100%) rename python/damask/{solver => _solver}/solver.py (100%) rename python/damask/{table.py => _table.py} (100%) rename python/damask/{test.py => _test.py} (100%) diff --git a/python/damask/__init__.py b/python/damask/__init__.py index 7951c63e1..7933651da 100644 --- a/python/damask/__init__.py +++ b/python/damask/__init__.py @@ -8,18 +8,18 @@ with open(_os.path.join(_os.path.dirname(__file__),'VERSION')) as _f: # classes from ._environment import Environment # noqa -from .table import Table # noqa +from ._table import Table # noqa from ._vtk import VTK # noqa -from .colormaps import Colormap, Color # noqa -from .rotation import Rotation # noqa -from .lattice import Symmetry, Lattice# noqa -from .orientation import Orientation # noqa +from ._colormaps import Colormap, Color # noqa +from ._rotation import Rotation # noqa +from ._lattice import Symmetry, Lattice# noqa +from ._orientation import Orientation # noqa from ._result import Result # noqa from ._geom import Geom # noqa -from .solver import Solver # noqa +from ._solver import Solver # noqa # deprecated -from .asciitable import ASCIItable # noqa +from ._asciitable import ASCIItable # noqa +from ._config import Material # noqa +from ._test import Test # noqa from .util import extendableOption # noqa -from .config import Material # noqa -from .test import Test # noqa diff --git a/python/damask/asciitable.py b/python/damask/_asciitable.py similarity index 100% rename from python/damask/asciitable.py rename to python/damask/_asciitable.py diff --git a/python/damask/colormaps.py b/python/damask/_colormaps.py similarity index 100% rename from python/damask/colormaps.py rename to python/damask/_colormaps.py diff --git a/python/damask/config/__init__.py b/python/damask/_config/__init__.py similarity index 100% rename from python/damask/config/__init__.py rename to python/damask/_config/__init__.py diff --git a/python/damask/config/material.py b/python/damask/_config/material.py similarity index 100% rename from python/damask/config/material.py rename to python/damask/_config/material.py diff --git a/python/damask/lattice.py b/python/damask/_lattice.py similarity index 99% rename from python/damask/lattice.py rename to python/damask/_lattice.py index 3c949b02c..42aa0e9bd 100644 --- a/python/damask/lattice.py +++ b/python/damask/_lattice.py @@ -1,10 +1,8 @@ import numpy as np -from .rotation import Rotation +from . import Rotation -P = -1 -# ****************************************************************************************** class Symmetry: """ Symmetry operations for lattice systems. diff --git a/python/damask/orientation.py b/python/damask/_orientation.py similarity index 99% rename from python/damask/orientation.py rename to python/damask/_orientation.py index d3f42c8d1..6cbe4f7d4 100644 --- a/python/damask/orientation.py +++ b/python/damask/_orientation.py @@ -1,7 +1,7 @@ import numpy as np -from .lattice import Lattice -from .rotation import Rotation +from . import Lattice +from . import Rotation class Orientation: """ diff --git a/python/damask/rotation.py b/python/damask/_rotation.py similarity index 100% rename from python/damask/rotation.py rename to python/damask/_rotation.py diff --git a/python/damask/solver/__init__.py b/python/damask/_solver/__init__.py similarity index 100% rename from python/damask/solver/__init__.py rename to python/damask/_solver/__init__.py diff --git a/python/damask/solver/marc.py b/python/damask/_solver/marc.py similarity index 100% rename from python/damask/solver/marc.py rename to python/damask/_solver/marc.py diff --git a/python/damask/solver/solver.py b/python/damask/_solver/solver.py similarity index 100% rename from python/damask/solver/solver.py rename to python/damask/_solver/solver.py diff --git a/python/damask/table.py b/python/damask/_table.py similarity index 100% rename from python/damask/table.py rename to python/damask/_table.py diff --git a/python/damask/test.py b/python/damask/_test.py similarity index 100% rename from python/damask/test.py rename to python/damask/_test.py From 4d4f3218726a91a42b5279f9534f4417a2c1dec6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 20 Mar 2020 08:49:33 +0100 Subject: [PATCH 5/5] following python convention --- python/damask/_Lambert.py | 6 +++--- python/damask/mechanics.py | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/python/damask/_Lambert.py b/python/damask/_Lambert.py index 3524d3567..b3f159ff6 100644 --- a/python/damask/_Lambert.py +++ b/python/damask/_Lambert.py @@ -59,7 +59,7 @@ def cube_to_ball(cube): ball = np.zeros(3) else: # get pyramide and scale by grid parameter ratio - p = get_order(cube) + p = _get_order(cube) XYZ = cube[p] * sc # intercept all the points along the z-axis @@ -109,7 +109,7 @@ def ball_to_cube(ball): if np.allclose(ball,0.0,rtol=0.0,atol=1.0e-300): cube = np.zeros(3) else: - p = get_order(ball) + p = _get_order(ball) xyz3 = ball[p] # inverse M_3 @@ -137,7 +137,7 @@ def ball_to_cube(ball): return cube -def get_order(xyz): +def _get_order(xyz): """ Get order of the coordinates. diff --git a/python/damask/mechanics.py b/python/damask/mechanics.py index 63927e05d..674ff9c5a 100644 --- a/python/damask/mechanics.py +++ b/python/damask/mechanics.py @@ -85,7 +85,7 @@ def left_stretch(T): Tensor of which the left stretch is computed. """ - return __polar_decomposition(T,'V')[0] + return _polar_decomposition(T,'V')[0] def maximum_shear(T_sym): @@ -113,7 +113,7 @@ def Mises_strain(epsilon): Symmetric strain tensor of which the von Mises equivalent is computed. """ - return __Mises(epsilon,2.0/3.0) + return _Mises(epsilon,2.0/3.0) def Mises_stress(sigma): @@ -126,7 +126,7 @@ def Mises_stress(sigma): Symmetric stress tensor of which the von Mises equivalent is computed. """ - return __Mises(sigma,3.0/2.0) + return _Mises(sigma,3.0/2.0) def PK2(P,F): @@ -158,7 +158,7 @@ def right_stretch(T): Tensor of which the right stretch is computed. """ - return __polar_decomposition(T,'U')[0] + return _polar_decomposition(T,'U')[0] def rotational_part(T): @@ -171,7 +171,7 @@ def rotational_part(T): Tensor of which the rotational part is computed. """ - return __polar_decomposition(T,'R')[0] + return _polar_decomposition(T,'R')[0] def spherical_part(T,tensor=False): @@ -262,7 +262,7 @@ def transpose(T): np.transpose(T,(0,2,1)) -def __polar_decomposition(T,requested): +def _polar_decomposition(T,requested): """ Singular value decomposition. @@ -290,7 +290,7 @@ def __polar_decomposition(T,requested): return tuple(output) -def __Mises(T_sym,s): +def _Mises(T_sym,s): """ Base equation for Mises equivalent of a stres or strain tensor.