Skip to content

Commit

Permalink
pytest-compatible access to np.float128, np.complex256
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf W. Grosse-Kunstleve committed May 19, 2023
1 parent d9e3bd3 commit e9a289c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/test_buffers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@

np = pytest.importorskip("numpy")

if m.std_is_same_double_long_double: # Windows.
np_float128 = None
np_complex256 = None
else:
np_float128 = np.float128
np_complex256 = np.complex256

def np_dtype_long_double_or_none(name):
# Intentionally not using getattr(np, name, None), to be strict.
if m.std_is_same_double_long_double: # Windows.
return None
return getattr(np, name)


CPP_NAME_FORMAT_NP_DTYPE_TABLE = [
item
Expand All @@ -32,10 +33,10 @@
("std::uint64_t", "Q", np.uint64),
("float", "f", np.float32),
("double", "d", np.float64),
("long double", "g", np_float128),
("long double", "g", np_dtype_long_double_or_none("float128")),
("std::complex<float>", "Zf", np.complex64),
("std::complex<double>", "Zd", np.complex128),
("std::complex<long double>", "Zg", np_complex256),
("std::complex<long double>", "Zg", np_dtype_long_double_or_none("complex256")),
]
if item[-1] is not None
]
Expand Down

0 comments on commit e9a289c

Please sign in to comment.