correct type handling

no reason to calculate fill twice
This commit is contained in:
Martin Diehl 2020-08-25 08:46:08 +02:00
parent 96d4975fc4
commit 800dac5d01
1 changed files with 4 additions and 6 deletions

View File

@ -769,16 +769,14 @@ class Geom:
offset : numpy.ndarray of shape (3) offset : numpy.ndarray of shape (3)
Offset (measured in grid points) from old to new microstructure[0,0,0]. Offset (measured in grid points) from old to new microstructure[0,0,0].
fill : int or float, optional 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 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, canvas = np.full(self.grid if grid is None else grid,fill,dtype)
np.nanmax(self.microstructure)+1 if fill is None else fill,
dtype)
LL = np.clip( offset, 0,np.minimum(self.grid, grid+offset)) LL = np.clip( offset, 0,np.minimum(self.grid, grid+offset))
UR = np.clip( offset+grid, 0,np.minimum(self.grid, grid+offset)) UR = np.clip( offset+grid, 0,np.minimum(self.grid, grid+offset))