From f928bd5e5b3d958b885891555978000e4e413345 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 19 Jul 2018 16:26:30 +0200 Subject: [PATCH] more python 3 compatibility --- processing/post/addDeterminant.py | 5 ++--- processing/post/addDeviator.py | 4 ++-- processing/post/addDisplacement.py | 8 +------- processing/post/addEhkl.py | 4 ++-- processing/post/addEuclideanDistance.py | 10 ++-------- 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/processing/post/addDeterminant.py b/processing/post/addDeterminant.py index 7196051e5..6d992b6f5 100755 --- a/processing/post/addDeterminant.py +++ b/processing/post/addDeterminant.py @@ -83,10 +83,9 @@ for name in filenames: while outputAlive and table.data_read(): # read next data line of ASCII table for type, data in items.items(): for column in data['column']: - table.data_append(determinant(map(float,table.data[column: - column+data['dim']]))) + table.data_append(determinant(list(map(float,table.data[column: column+data['dim']])))) outputAlive = table.data_write() # output processed line # ------------------------------------------ output finalization ----------------------------------- - table.close() # close input ASCII table (works for stdin) \ No newline at end of file + table.close() # close input ASCII table (works for stdin) diff --git a/processing/post/addDeviator.py b/processing/post/addDeviator.py index 4df8a6803..86fcac509 100755 --- a/processing/post/addDeviator.py +++ b/processing/post/addDeviator.py @@ -95,8 +95,8 @@ for name in filenames: while outputAlive and table.data_read(): # read next data line of ASCII table for type, data in items.items(): for column in data['column']: - table.data_append(deviator(map(float,table.data[column: - column+data['dim']]),options.spherical)) + table.data_append(deviator(list(map(float,table.data[column: + column+data['dim']])),options.spherical)) outputAlive = table.data_write() # output processed line # ------------------------------------------ output finalization ----------------------------------- diff --git a/processing/post/addDisplacement.py b/processing/post/addDisplacement.py index bc1d7377b..00132d7c6 100755 --- a/processing/post/addDisplacement.py +++ b/processing/post/addDisplacement.py @@ -168,13 +168,7 @@ for name in filenames: np.zeros((table.data.shape[0], 3-table.data[:,9:].shape[1]),dtype='f'))) # fill coords up to 3D with zeros - coords = [np.unique(table.data[:,9+i]) for i in range(3)] - mincorner = np.array(map(min,coords)) - maxcorner = np.array(map(max,coords)) - grid = np.array(map(len,coords),'i') - size = grid/np.maximum(np.ones(3,'d'), grid-1.0) * (maxcorner-mincorner) # size from edge to edge = dim * n/(n-1) - size = np.where(grid > 1, size, min(size[grid > 1]/grid[grid > 1])) # spacing for grid==1 set to smallest among other spacings - + grid,size = damask.util.coordGridAndSize(table.data[:,9:12]) N = grid.prod() if N != len(table.data): errors.append('data count {} does not match grid {}x{}x{}.'.format(N,*grid)) diff --git a/processing/post/addEhkl.py b/processing/post/addEhkl.py index f7a143466..59f678118 100755 --- a/processing/post/addEhkl.py +++ b/processing/post/addEhkl.py @@ -88,9 +88,9 @@ for name in filenames: outputAlive = True while outputAlive and table.data_read(): # read next data line of ASCII table for column in columns: - table.data_append(E_hkl(map(float,table.data[column:column+3]),options.hkl)) + table.data_append(E_hkl(list(map(float,table.data[column:column+3])),options.hkl)) outputAlive = table.data_write() # output processed line # ------------------------------------------ output finalization ----------------------------------- - table.close() # close ASCII tables \ No newline at end of file + table.close() # close ASCII tables diff --git a/processing/post/addEuclideanDistance.py b/processing/post/addEuclideanDistance.py index b83c36b6c..b3f972fc7 100755 --- a/processing/post/addEuclideanDistance.py +++ b/processing/post/addEuclideanDistance.py @@ -151,10 +151,8 @@ for name in filenames: remarks = [] column = {} - coordDim = table.label_dimension(options.pos) - if not 3 >= coordDim >= 1: + if not 3 >= table.label_dimension(options.pos) >= 1: errors.append('coordinates "{}" need to have one, two, or three dimensions.'.format(options.pos)) - else: coordCol = table.label_index(options.pos) if table.label_dimension(options.id) != 1: errors.append('grain identifier {} not found.'.format(options.id)) else: idCol = table.label_index(options.id) @@ -178,11 +176,7 @@ for name in filenames: table.data_readArray() - coords = [np.unique(table.data[:,coordCol+i]) for i in range(coordDim)] - mincorner = np.array(map(min,coords)) - maxcorner = np.array(map(max,coords)) - grid = np.array(map(len,coords)+[1]*(3-len(coords)),'i') - + grid,size = damask.util.coordGridAndSize(table.data[:,table.label_indexrange(options.pos)]) N = grid.prod() if N != len(table.data): errors.append('data count {} does not match grid {}.'.format(N,'x'.join(map(str,grid))))