Merge branch 'numpy_dtype_int_to_int64' into 'development'
Prevent windows overflow error when using numpy dtype=int instead of int64 Closes #175 See merge request damask/DAMASK!598
This commit is contained in:
commit
49e40923e5
|
@ -385,7 +385,7 @@ class Colormap(mpl.colors.ListedColormap):
|
|||
GOM_str = '1 1 {name} 9 {name} '.format(name=self.name.replace(" ","_")) \
|
||||
+ '0 1 0 3 0 0 -1 9 \\ 0 0 0 255 255 255 0 0 255 ' \
|
||||
+ f'30 NO_UNIT 1 1 64 64 64 255 1 0 0 0 0 0 0 3 0 {self.N}' \
|
||||
+ ' '.join([f' 0 {c[0]} {c[1]} {c[2]} 255 1' for c in reversed((self.colors*255).astype(int))]) \
|
||||
+ ' '.join([f' 0 {c[0]} {c[1]} {c[2]} 255 1' for c in reversed((self.colors*255).astype(np.int64))]) \
|
||||
+ '\n'
|
||||
|
||||
self._get_file_handle(fname,'.legend').write(GOM_str)
|
||||
|
|
|
@ -117,8 +117,8 @@ class Grid:
|
|||
self._material = np.copy(material)
|
||||
|
||||
if self.material.dtype in np.sctypes['float'] and \
|
||||
np.all(self.material == self.material.astype(int).astype(float)):
|
||||
self._material = self.material.astype(int)
|
||||
np.all(self.material == self.material.astype(np.int64).astype(float)):
|
||||
self._material = self.material.astype(np.int64)
|
||||
|
||||
|
||||
@property
|
||||
|
@ -285,7 +285,7 @@ class Grid:
|
|||
raise TypeError(f'mismatch between {cells.prod()} expected entries and {i} found')
|
||||
|
||||
if not np.any(np.mod(material,1) != 0.0): # no float present
|
||||
material = material.astype(int) - (1 if material.min() > 0 else 0)
|
||||
material = material.astype(np.int64) - (1 if material.min() > 0 else 0)
|
||||
|
||||
return Grid(material = material.reshape(cells,order='F'),
|
||||
size = size,
|
||||
|
@ -916,7 +916,7 @@ class Grid:
|
|||
cval=np.nanmax(self.material) + 1 if fill is None else fill)
|
||||
# avoid scipy interpolation errors for rotations close to multiples of 90°
|
||||
material = material_temp if np.prod(material_temp.shape) != np.prod(material.shape) else \
|
||||
np.rot90(material,k=np.rint(angle/90.).astype(int),axes=axes)
|
||||
np.rot90(material,k=np.rint(angle/90.).astype(np.int64),axes=axes)
|
||||
|
||||
origin = self.origin-(np.asarray(material.shape)-self.cells)*.5 * self.size/self.cells
|
||||
|
||||
|
@ -1094,7 +1094,7 @@ class Grid:
|
|||
|
||||
rng = np.random.default_rng(rng_seed)
|
||||
|
||||
d = np.floor(distance).astype(int)
|
||||
d = np.floor(distance).astype(np.int64)
|
||||
ext = np.linspace(-d,d,1+2*d,dtype=float),
|
||||
xx,yy,zz = np.meshgrid(ext,ext,ext)
|
||||
footprint = xx**2+yy**2+zz**2 <= distance**2+distance*1e-8
|
||||
|
@ -1197,7 +1197,7 @@ class Grid:
|
|||
mask = np.sum(np.power(coords_rot/r,2.0**np.array(exponent)),axis=-1) > 1.0
|
||||
|
||||
if periodic: # translate back to center
|
||||
mask = np.roll(mask,((c/self.size-0.5)*self.cells).round().astype(int),(0,1,2))
|
||||
mask = np.roll(mask,((c/self.size-0.5)*self.cells).round().astype(np.int64),(0,1,2))
|
||||
|
||||
return Grid(material = np.where(np.logical_not(mask) if inverse else mask,
|
||||
self.material,
|
||||
|
@ -1249,7 +1249,7 @@ class Grid:
|
|||
return np.any(stencil != me if selection is None else
|
||||
np.in1d(stencil,np.array(list(selection - {me}))))
|
||||
|
||||
d = np.floor(distance).astype(int)
|
||||
d = np.floor(distance).astype(np.int64)
|
||||
ext = np.linspace(-d,d,1+2*d,dtype=float),
|
||||
xx,yy,zz = np.meshgrid(ext,ext,ext)
|
||||
footprint = xx**2+yy**2+zz**2 <= distance**2+distance*1e-8
|
||||
|
|
|
@ -134,7 +134,7 @@ class Table:
|
|||
labels = []
|
||||
for label in what:
|
||||
shape = self.shapes[label]
|
||||
size = np.prod(shape,dtype=int)
|
||||
size = np.prod(shape,dtype=np.int64)
|
||||
if how == 'uniform':
|
||||
labels += [label] * size
|
||||
elif how == 'shapes':
|
||||
|
@ -168,7 +168,7 @@ class Table:
|
|||
shape: Tuple[int, ...],
|
||||
info: str = None):
|
||||
if info is not None:
|
||||
specific = f'{label}{" "+str(shape) if np.prod(shape,dtype=int) > 1 else ""}: {info}'
|
||||
specific = f'{label}{" "+str(shape) if np.prod(shape,dtype=np.int64) > 1 else ""}: {info}'
|
||||
general = util.execution_stamp('Table')
|
||||
self.comments.append(f'{specific} / {general}')
|
||||
|
||||
|
@ -401,7 +401,7 @@ class Table:
|
|||
else:
|
||||
|
||||
dup.shapes[label] = data.shape[1:] if len(data.shape) > 1 else (1,)
|
||||
size = np.prod(data.shape[1:],dtype=int)
|
||||
size = np.prod(data.shape[1:],dtype=np.int64)
|
||||
new = pd.DataFrame(data=data.reshape(-1,size),
|
||||
columns=[label]*size,
|
||||
)
|
||||
|
|
|
@ -187,7 +187,7 @@ class VTK:
|
|||
----------
|
||||
nodes : numpy.ndarray, shape (:,3)
|
||||
Spatial position of the nodes.
|
||||
connectivity : numpy.ndarray of np.dtype = int
|
||||
connectivity : numpy.ndarray of np.dtype = np.int64
|
||||
Cell connectivity (0-based), first dimension determines #Cells,
|
||||
second dimension determines #Nodes/Cell.
|
||||
cell_type : str
|
||||
|
|
|
@ -45,7 +45,7 @@ def from_random(size: _FloatSequence,
|
|||
else:
|
||||
grid_coords = _grid_filters.coordinates0_point(cells,size).reshape(-1,3,order='F')
|
||||
coords = grid_coords[rng.choice(_np.prod(cells),N_seeds, replace=False)] \
|
||||
+ _np.broadcast_to(size_/_np.array(cells,int),(N_seeds,3))*(rng.random((N_seeds,3))*.5-.25) # wobble w/o leaving grid
|
||||
+ _np.broadcast_to(size_/_np.array(cells,_np.int64),(N_seeds,3))*(rng.random((N_seeds,3))*.5-.25) # wobble w/o leaving grid
|
||||
|
||||
return coords
|
||||
|
||||
|
|
|
@ -314,7 +314,7 @@ def scale_to_coprime(v: FloatSequence) -> np.ndarray:
|
|||
return a * b // np.gcd(a, b)
|
||||
|
||||
v_ = np.array(v)
|
||||
m = (v_ * reduce(lcm, map(lambda x: int(get_square_denominator(x)),v_))**0.5).astype(int)
|
||||
m = (v_ * reduce(lcm, map(lambda x: int(get_square_denominator(x)),v_))**0.5).astype(np.int64)
|
||||
m = m//reduce(np.gcd,m)
|
||||
|
||||
with np.errstate(invalid='ignore'):
|
||||
|
|
Loading…
Reference in New Issue