Skip to content

Commit b29be01

Browse files
committed
Add a test for np.bool_
1 parent 5c25cdc commit b29be01

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

tests/test_numpy_dtypes.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ test_initializer numpy_dtypes([](py::module &m) {
467467
m.def("f_packed", [](PackedStruct s) { return s.uint_ * 10; });
468468
m.def("f_nested", [](NestedStruct s) { return s.a.uint_ * 10; });
469469
m.def("register_dtype", []() { PYBIND11_NUMPY_DTYPE(SimpleStruct, bool_, uint_, float_, ldbl_); });
470+
m.def("negate_bool", [](bool arg) { return !arg; });
470471
});
471472

472473
#undef PYBIND11_PACKED

tests/test_numpy_dtypes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,10 @@ def test_register_dtype():
319319
def test_compare_buffer_info():
320320
from pybind11_tests import compare_buffer_info
321321
assert all(compare_buffer_info())
322+
323+
324+
@pytest.requires_numpy
325+
def test_numpy_bool():
326+
from pybind11_tests import negate_bool
327+
assert negate_bool(np.bool_(True)) is False
328+
assert negate_bool(np.bool_(False)) is True

0 commit comments

Comments
 (0)