From 4c5939ef233ff4021d0f836f836df3d21ae25c91 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 20 Jun 2020 22:51:00 +0200 Subject: [PATCH] small polishing --- python/damask/util.py | 14 +++++++------- python/tests/test_Rotation.py | 4 ++-- python/tests/test_util.py | 11 +++++++++++ src/discretization.f90 | 2 +- 4 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 python/tests/test_util.py diff --git a/python/damask/util.py b/python/damask/util.py index cb1d8757d..a3fc71d3a 100644 --- a/python/damask/util.py +++ b/python/damask/util.py @@ -93,7 +93,7 @@ def strikeout(what): def execute(cmd, - streamIn = None, + stream_in = None, wd = './', env = None): """ @@ -103,7 +103,7 @@ def execute(cmd, ---------- cmd : str Command to be executed. - streanIn :, optional + stream_in : file object, optional Input (via pipe) for executed process. wd : str, optional Working directory of process. Defaults to ./ . @@ -119,14 +119,14 @@ def execute(cmd, stderr = subprocess.PIPE, stdin = subprocess.PIPE, env = myEnv) - out,error = [i for i in (process.communicate() if streamIn is None - else process.communicate(streamIn.read().encode('utf-8')))] + stdout, stderr = [i for i in (process.communicate() if stream_in is None + else process.communicate(stream_in.read().encode('utf-8')))] os.chdir(initialPath) - out = out.decode('utf-8').replace('\x08','') - error = error.decode('utf-8').replace('\x08','') + stdout = stdout.decode('utf-8').replace('\x08','') + stderr = stderr.decode('utf-8').replace('\x08','') if process.returncode != 0: raise RuntimeError('{} failed with returncode {}'.format(cmd,process.returncode)) - return out,error + return stdout, stderr def show_progress(iterable,N_iter=None,prefix='',bar_length=50): diff --git a/python/tests/test_Rotation.py b/python/tests/test_Rotation.py index 933719d6f..86e5fa2a7 100644 --- a/python/tests/test_Rotation.py +++ b/python/tests/test_Rotation.py @@ -950,14 +950,14 @@ class TestRotation: def test_rotate_inverse(self): R = Rotation.from_random() - assert np.allclose(np.eye(3),(R.inversed()@R).as_matrix()) + assert np.allclose(np.eye(3),(~R@R).as_matrix()) @pytest.mark.parametrize('data',[np.random.rand(3), np.random.rand(3,3), np.random.rand(3,3,3,3)]) def test_rotate_inverse_array(self,data): R = Rotation.from_random() - assert np.allclose(data,R.inversed()@(R@data)) + assert np.allclose(data,~R@(R@data)) @pytest.mark.parametrize('data',[np.random.rand(4), np.random.rand(3,2), diff --git a/python/tests/test_util.py b/python/tests/test_util.py new file mode 100644 index 000000000..e67478d82 --- /dev/null +++ b/python/tests/test_util.py @@ -0,0 +1,11 @@ +from damask import util + +class TestUtil: + + def test_execute_direct(self): + out,err = util.execute('echo test') + assert out=='test\n' and err=='' + + def test_execute_env(self): + out,err = util.execute('sh -c "echo $test_for_execute"',env={'test_for_execute':'test'}) + assert out=='test\n' and err=='' diff --git a/src/discretization.f90 b/src/discretization.f90 index 16f76b158..e52784c6d 100644 --- a/src/discretization.f90 +++ b/src/discretization.f90 @@ -49,7 +49,7 @@ subroutine discretization_init(homogenizationAt,microstructureAt,& IPcoords0, & NodeCoords0 integer, optional, intent(in) :: & - sharedNodesBegin ! index of first node shared among different processes (MPI) + sharedNodesBegin !< index of first node shared among different processes (MPI) write(6,'(/,a)') ' <<<+- discretization init -+>>>'; flush(6)