mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-21 20:55:11 +00:00
pytest-compatible access to np.float128, np.complex256
This commit is contained in:
parent
d9e3bd3248
commit
e9a289c50f
@ -10,12 +10,13 @@ from pybind11_tests import buffers as m
|
||||
|
||||
np = pytest.importorskip("numpy")
|
||||
|
||||
|
||||
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.
|
||||
np_float128 = None
|
||||
np_complex256 = None
|
||||
else:
|
||||
np_float128 = np.float128
|
||||
np_complex256 = np.complex256
|
||||
return None
|
||||
return getattr(np, name)
|
||||
|
||||
|
||||
CPP_NAME_FORMAT_NP_DTYPE_TABLE = [
|
||||
item
|
||||
@ -32,10 +33,10 @@ CPP_NAME_FORMAT_NP_DTYPE_TABLE = [
|
||||
("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
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user