mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Stop py::array_t arguments from accepting arrays that do not match the C- or F-contiguity flags (#2484)
* Stop py::array_t arguments from accepting arrays that do not match the C- or F-contiguity flags * Add trivially-contiguous arrays to the tests
This commit is contained in:
@@ -385,4 +385,42 @@ TEST_SUBMODULE(numpy_array, sm) {
|
||||
sm.def("index_using_ellipsis", [](py::array a) {
|
||||
return a[py::make_tuple(0, py::ellipsis(), 0)];
|
||||
});
|
||||
|
||||
// test_argument_conversions
|
||||
sm.def("accept_double",
|
||||
[](py::array_t<double, 0>) {},
|
||||
py::arg("a"));
|
||||
sm.def("accept_double_forcecast",
|
||||
[](py::array_t<double, py::array::forcecast>) {},
|
||||
py::arg("a"));
|
||||
sm.def("accept_double_c_style",
|
||||
[](py::array_t<double, py::array::c_style>) {},
|
||||
py::arg("a"));
|
||||
sm.def("accept_double_c_style_forcecast",
|
||||
[](py::array_t<double, py::array::forcecast | py::array::c_style>) {},
|
||||
py::arg("a"));
|
||||
sm.def("accept_double_f_style",
|
||||
[](py::array_t<double, py::array::f_style>) {},
|
||||
py::arg("a"));
|
||||
sm.def("accept_double_f_style_forcecast",
|
||||
[](py::array_t<double, py::array::forcecast | py::array::f_style>) {},
|
||||
py::arg("a"));
|
||||
sm.def("accept_double_noconvert",
|
||||
[](py::array_t<double, 0>) {},
|
||||
py::arg("a").noconvert());
|
||||
sm.def("accept_double_forcecast_noconvert",
|
||||
[](py::array_t<double, py::array::forcecast>) {},
|
||||
py::arg("a").noconvert());
|
||||
sm.def("accept_double_c_style_noconvert",
|
||||
[](py::array_t<double, py::array::c_style>) {},
|
||||
py::arg("a").noconvert());
|
||||
sm.def("accept_double_c_style_forcecast_noconvert",
|
||||
[](py::array_t<double, py::array::forcecast | py::array::c_style>) {},
|
||||
py::arg("a").noconvert());
|
||||
sm.def("accept_double_f_style_noconvert",
|
||||
[](py::array_t<double, py::array::f_style>) {},
|
||||
py::arg("a").noconvert());
|
||||
sm.def("accept_double_f_style_forcecast_noconvert",
|
||||
[](py::array_t<double, py::array::forcecast | py::array::f_style>) {},
|
||||
py::arg("a").noconvert());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user