From 88206d307b590cf1d0455a9f627910695274f539 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Mon, 7 Nov 2022 18:13:10 +0100 Subject: [PATCH 1/2] default was incorrect and some useful examples added --- python/damask/_rotation.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index 229e1324e..fb09b036e 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -1120,11 +1120,29 @@ class Rotation: shape : int or sequence of ints, optional Shape of the returned array. Defaults to None, which gives a scalar. degrees : bool, optional - sigma is given in degrees. Defaults to True. + sigma is given in degrees. Defaults to False. rng_seed : {None, int, array_like[ints], SeedSequence, BitGenerator, Generator}, optional A seed to initialize the BitGenerator. Defaults to None, i.e. unpredictable entropy will be pulled from the OS. + Examples + -------- + Create a brass texture consisting of + 200 orientations: + + >>> import damask + >>> import numpy as np + >>> center = damask.Rotation.from_Euler_angles([35.0,45.0,0.0],degrees=True) + >>> brass = damask.Rotation.from_spherical_component(center=center,sigma=3.0,shape=200,degrees=True) + + Create a Goss texture consisting of + 100 orientations: + + >>> import damask + >>> import numpy as np + >>> center = damask.Rotation.from_Euler_angles([0.0,45.0,0.0],degrees=True) + >>> goss = damask.Rotation.from_spherical_component(center=center,sigma=3.0,shape=100,degrees=True) + """ rng = np.random.default_rng(rng_seed) sigma = np.radians(sigma) if degrees else sigma @@ -1162,7 +1180,7 @@ class Rotation: shape : int or sequence of ints, optional Shape of the returned array. Defaults to None, which gives a scalar. degrees : bool, optional - sigma and polar coordinates are given in degrees. + sigma and polar coordinates are given in degrees. Defaults to False. rng_seed : {None, int, array_like[ints], SeedSequence, BitGenerator, Generator}, optional A seed to initialize the BitGenerator. Defaults to None, i.e. unpredictable entropy will be pulled from the OS. From 868a4dda96c5c1a383eaa91d2e678dfda3738f4b Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 7 Nov 2022 14:56:38 -0500 Subject: [PATCH 2/2] remove numpy where unnecessary --- python/damask/_rotation.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index fb09b036e..b72cec402 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -611,8 +611,7 @@ class Rotation: Cube orientation as Bunge Euler angles. >>> import damask - >>> import numpy as np - >>> damask.Rotation(np.array([1,0,0,0])).as_Euler_angles() + >>> damask.Rotation([1,0,0,0]).as_Euler_angles() array([0., 0., 0.]) """ @@ -643,8 +642,7 @@ class Rotation: Cube orientation as axis–angle pair. >>> import damask - >>> import numpy as np - >>> damask.Rotation(np.array([1,0,0,0])).as_axis_angle(pair=True) + >>> damask.Rotation([1,0,0,0]).as_axis_angle(pair=True) (array([0., 0., 1.]), array(0.)) """ @@ -666,8 +664,7 @@ class Rotation: Cube orientation as rotation matrix. >>> import damask - >>> import numpy as np - >>> damask.Rotation(np.array([1,0,0,0])).as_matrix() + >>> damask.Rotation([1,0,0,0]).as_matrix() array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]) @@ -697,8 +694,7 @@ class Rotation: Cube orientation as three-component Rodrigues–Frank vector. >>> import damask - >>> import numpy as np - >>> damask.Rotation(np.array([1,0,0,0])).as_Rodrigues_vector(compact=True) + >>> damask.Rotation([1,0,0,0]).as_Rodrigues_vector(compact=True) array([ 0., 0., 0.]) """ @@ -723,8 +719,7 @@ class Rotation: Cube orientation as homochoric vector. >>> import damask - >>> import numpy as np - >>> damask.Rotation(np.array([1,0,0,0])).as_homochoric() + >>> damask.Rotation([1,0,0,0]).as_homochoric() array([0., 0., 0.]) """ @@ -744,8 +739,7 @@ class Rotation: Cube orientation as cubochoric vector. >>> import damask - >>> import numpy as np - >>> damask.Rotation(np.array([1,0,0,0])).as_cubochoric() + >>> damask.Rotation([1,0,0,0]).as_cubochoric() array([0., 0., 0.]) """ @@ -1131,7 +1125,6 @@ class Rotation: 200 orientations: >>> import damask - >>> import numpy as np >>> center = damask.Rotation.from_Euler_angles([35.0,45.0,0.0],degrees=True) >>> brass = damask.Rotation.from_spherical_component(center=center,sigma=3.0,shape=200,degrees=True) @@ -1139,7 +1132,6 @@ class Rotation: 100 orientations: >>> import damask - >>> import numpy as np >>> center = damask.Rotation.from_Euler_angles([0.0,45.0,0.0],degrees=True) >>> goss = damask.Rotation.from_spherical_component(center=center,sigma=3.0,shape=100,degrees=True)