From b00b4bb0ad42b780c463edf0efed88319a6b8844 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 19 Feb 2021 16:37:02 +0100 Subject: [PATCH] more general handling of precision Anaconda on windows does not have np.float128 defined, but aliases should work https://numpy.org/devdocs/user/basics.types.html --- python/damask/_grid.py | 2 +- python/damask/_vtk.py | 4 ++-- python/setup.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/damask/_grid.py b/python/damask/_grid.py index 103538349..7e4ef2ac1 100644 --- a/python/damask/_grid.py +++ b/python/damask/_grid.py @@ -760,7 +760,7 @@ class Grid: """ if fill is None: fill = np.nanmax(self.material) + 1 - dtype = float if np.isnan(fill) or int(fill) != fill or self.material.dtype==np.float else int + dtype = float if isinstance(fill,float) or self.material.dtype in np.sctypes['float'] else int material = self.material # These rotations are always applied in the reference coordinate system, i.e. (z,x,z) not (z,x',z'') diff --git a/python/damask/_vtk.py b/python/damask/_vtk.py index 00a07efa5..b9f237297 100644 --- a/python/damask/_vtk.py +++ b/python/damask/_vtk.py @@ -246,8 +246,8 @@ class VTK: raise ValueError('No label defined for numpy.ndarray') N_data = data.shape[0] - d = np_to_vtk((data.astype(np.float32) if data.dtype in [np.float64, np.float128] - else data).reshape(N_data,-1),deep=True) # avoid large files + d = np_to_vtk((data.astype(np.single) if data.dtype in [np.double, np.longdouble] else + data).reshape(N_data,-1),deep=True) # avoid large files d.SetName(label) if N_data == N_points: diff --git a/python/setup.py b/python/setup.py index 3df226141..0642c0b7d 100644 --- a/python/setup.py +++ b/python/setup.py @@ -15,7 +15,7 @@ setuptools.setup( url='https://damask.mpie.de', packages=setuptools.find_packages(), include_package_data=True, - python_requires = '>=3.6' + python_requires = '>=3.6', install_requires = [ 'pandas>=0.24', # requires numpy 'scipy>=1.2',