From 8d793fcf9b0b7b143cbf9fbc6d96bd09d2eeee65 Mon Sep 17 00:00:00 2001 From: Thomas Baumann <39156931+brownbaerchen@users.noreply.github.com> Date: Tue, 21 Jan 2025 15:32:01 +0000 Subject: [PATCH 1/3] Fix for missing numpy data types on some platforms --- pySDC/helpers/fieldsIO.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pySDC/helpers/fieldsIO.py b/pySDC/helpers/fieldsIO.py index 4507a8bdbc..c3f704f9ee 100644 --- a/pySDC/helpers/fieldsIO.py +++ b/pySDC/helpers/fieldsIO.py @@ -69,8 +69,8 @@ class MPI: DTYPES = { 0: np.float64, # double precision 1: np.complex128, - 2: np.float128, # quadruple precision - 3: np.complex256, + 2: np.longdouble, # quadruple precision + 3: np.clongdouble, 4: np.float32, # single precision 5: np.complex64, } From 5fcddbe8d254f8097a4840498dd0dfc0b966e4ec Mon Sep 17 00:00:00 2001 From: Thomas Baumann <39156931+brownbaerchen@users.noreply.github.com> Date: Wed, 22 Jan 2025 09:45:21 +0000 Subject: [PATCH 2/3] Implemented @tlunet's suggestions --- pySDC/helpers/fieldsIO.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/pySDC/helpers/fieldsIO.py b/pySDC/helpers/fieldsIO.py index c3f704f9ee..8fa34f47a7 100644 --- a/pySDC/helpers/fieldsIO.py +++ b/pySDC/helpers/fieldsIO.py @@ -69,11 +69,30 @@ class MPI: DTYPES = { 0: np.float64, # double precision 1: np.complex128, - 2: np.longdouble, # quadruple precision - 3: np.clongdouble, - 4: np.float32, # single precision - 5: np.complex64, } +try: + DTYPES.update( + { + 2: np.float128, # quadruple precision + 3: np.complex256, + } + ) +except AttributeError: + import logging + + logging.getLogger('FieldsIO').debug('Warning: Quadruple precision not available on this machine') +try: + DTYPES.update( + { + 4: np.float32, # single precision + 5: np.complex64, + } + ) +except AttributeError: + import logging + + logging.getLogger('FieldsIO').debug('Warning: Single precision not available on this machine') + DTYPES_AVAIL = {val: key for key, val in DTYPES.items()} # Header dtype @@ -100,7 +119,7 @@ def __init__(self, dtype, fileName): fileName : str File. """ - assert dtype in DTYPES_AVAIL, f"{dtype=} not available" + assert dtype in DTYPES_AVAIL, f"{dtype=} not available. Supported on this machine: {list(DTYPES_AVAIL.keys())}" self.dtype = dtype self.fileName = fileName self.initialized = False From 6ee71638fdbe07e87d381cc639e255efd4bab3e5 Mon Sep 17 00:00:00 2001 From: Thomas Baumann <39156931+brownbaerchen@users.noreply.github.com> Date: Wed, 22 Jan 2025 09:49:42 +0000 Subject: [PATCH 3/3] Aesthetic changes --- pySDC/helpers/fieldsIO.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pySDC/helpers/fieldsIO.py b/pySDC/helpers/fieldsIO.py index 8fa34f47a7..82675ac652 100644 --- a/pySDC/helpers/fieldsIO.py +++ b/pySDC/helpers/fieldsIO.py @@ -49,6 +49,7 @@ import os import numpy as np from typing import Type, TypeVar +import logging T = TypeVar("T") @@ -78,8 +79,6 @@ class MPI: } ) except AttributeError: - import logging - logging.getLogger('FieldsIO').debug('Warning: Quadruple precision not available on this machine') try: DTYPES.update( @@ -89,8 +88,6 @@ class MPI: } ) except AttributeError: - import logging - logging.getLogger('FieldsIO').debug('Warning: Single precision not available on this machine') DTYPES_AVAIL = {val: key for key, val in DTYPES.items()}