Skip to content

Commit

Permalink
Add a test for np.bool_
Browse files Browse the repository at this point in the history
  • Loading branch information
aldanor committed Jun 27, 2017
1 parent 5c25cdc commit b29be01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/test_numpy_dtypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ test_initializer numpy_dtypes([](py::module &m) {
m.def("f_packed", [](PackedStruct s) { return s.uint_ * 10; });
m.def("f_nested", [](NestedStruct s) { return s.a.uint_ * 10; });
m.def("register_dtype", []() { PYBIND11_NUMPY_DTYPE(SimpleStruct, bool_, uint_, float_, ldbl_); });
m.def("negate_bool", [](bool arg) { return !arg; });
});

#undef PYBIND11_PACKED
7 changes: 7 additions & 0 deletions tests/test_numpy_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,10 @@ def test_register_dtype():
def test_compare_buffer_info():
from pybind11_tests import compare_buffer_info
assert all(compare_buffer_info())


@pytest.requires_numpy
def test_numpy_bool():
from pybind11_tests import negate_bool
assert negate_bool(np.bool_(True)) is False
assert negate_bool(np.bool_(False)) is True

0 comments on commit b29be01

Please sign in to comment.