From 800dac5d0171fb57bd92b75e6bb251a0e08d38d1 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 25 Aug 2020 08:46:08 +0200 Subject: [PATCH] correct type handling no reason to calculate fill twice --- python/damask/_geom.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/python/damask/_geom.py b/python/damask/_geom.py index 1dac0fa84..8daf5f476 100644 --- a/python/damask/_geom.py +++ b/python/damask/_geom.py @@ -769,16 +769,14 @@ class Geom: offset : numpy.ndarray of shape (3) Offset (measured in grid points) from old to new microstructure[0,0,0]. fill : int or float, optional - Microstructure index to fill the corners. Defaults to microstructure.max() + 1. + Microstructure index to fill the background. Defaults to microstructure.max() + 1. """ - if fill is None: fill = np.nanmax(self.microstructure) + 1 if offset is None: offset = 0 - dtype = float if int(fill) != fill or self.microstructure.dtype==np.float else int + if fill is None: fill = np.nanmax(self.microstructure) + 1 + dtype = float if int(fill) != fill or self.microstructure.dtype in np.sctypes['float'] else int - canvas = np.full(self.grid if grid is None else grid, - np.nanmax(self.microstructure)+1 if fill is None else fill, - dtype) + canvas = np.full(self.grid if grid is None else grid,fill,dtype) LL = np.clip( offset, 0,np.minimum(self.grid, grid+offset)) UR = np.clip( offset+grid, 0,np.minimum(self.grid, grid+offset))