Skip to content

Commit 5fcddbe

Browse files
committed
Implemented @tlunet's suggestions
1 parent 8d793fc commit 5fcddbe

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

pySDC/helpers/fieldsIO.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,30 @@ class MPI:
6969
DTYPES = {
7070
0: np.float64, # double precision
7171
1: np.complex128,
72-
2: np.longdouble, # quadruple precision
73-
3: np.clongdouble,
74-
4: np.float32, # single precision
75-
5: np.complex64,
7672
}
73+
try:
74+
DTYPES.update(
75+
{
76+
2: np.float128, # quadruple precision
77+
3: np.complex256,
78+
}
79+
)
80+
except AttributeError:
81+
import logging
82+
83+
logging.getLogger('FieldsIO').debug('Warning: Quadruple precision not available on this machine')
84+
try:
85+
DTYPES.update(
86+
{
87+
4: np.float32, # single precision
88+
5: np.complex64,
89+
}
90+
)
91+
except AttributeError:
92+
import logging
93+
94+
logging.getLogger('FieldsIO').debug('Warning: Single precision not available on this machine')
95+
7796
DTYPES_AVAIL = {val: key for key, val in DTYPES.items()}
7897

7998
# Header dtype
@@ -100,7 +119,7 @@ def __init__(self, dtype, fileName):
100119
fileName : str
101120
File.
102121
"""
103-
assert dtype in DTYPES_AVAIL, f"{dtype=} not available"
122+
assert dtype in DTYPES_AVAIL, f"{dtype=} not available. Supported on this machine: {list(DTYPES_AVAIL.keys())}"
104123
self.dtype = dtype
105124
self.fileName = fileName
106125
self.initialized = False

0 commit comments

Comments
 (0)