|
10 | 10 |
|
11 | 11 | np = pytest.importorskip("numpy")
|
12 | 12 |
|
13 |
| -if m.std_is_same_double_long_double: # Windows. |
14 |
| - np_float128 = None |
15 |
| - np_complex256 = None |
16 |
| -else: |
17 |
| - np_float128 = np.float128 |
18 |
| - np_complex256 = np.complex256 |
| 13 | + |
| 14 | +def np_dtype_long_double_or_none(name): |
| 15 | + # Intentionally not using getattr(np, name, None), to be strict. |
| 16 | + if m.std_is_same_double_long_double: # Windows. |
| 17 | + return None |
| 18 | + return getattr(np, name) |
| 19 | + |
19 | 20 |
|
20 | 21 | CPP_NAME_FORMAT_NP_DTYPE_TABLE = [
|
21 | 22 | item
|
|
32 | 33 | ("std::uint64_t", "Q", np.uint64),
|
33 | 34 | ("float", "f", np.float32),
|
34 | 35 | ("double", "d", np.float64),
|
35 |
| - ("long double", "g", np_float128), |
| 36 | + ("long double", "g", np_dtype_long_double_or_none("float128")), |
36 | 37 | ("std::complex<float>", "Zf", np.complex64),
|
37 | 38 | ("std::complex<double>", "Zd", np.complex128),
|
38 |
| - ("std::complex<long double>", "Zg", np_complex256), |
| 39 | + ("std::complex<long double>", "Zg", np_dtype_long_double_or_none("complex256")), |
39 | 40 | ]
|
40 | 41 | if item[-1] is not None
|
41 | 42 | ]
|
|
0 commit comments