mirror of
https://github.com/pybind/pybind11.git
synced 2026-06-06 07:51:47 +00:00
added py::ellipsis() method for slicing of multidimensional NumPy arrays
This PR adds a new py::ellipsis() method which can be used in conjunction with NumPy's generalized slicing support. For instance, the following is now valid (where "a" is a NumPy array): py::array b = a[py::make_tuple(0, py::ellipsis(), 0)];
This commit is contained in:
@@ -295,4 +295,10 @@ TEST_SUBMODULE(numpy_array, sm) {
|
||||
std::fill(a.mutable_data(), a.mutable_data() + a.size(), 42.);
|
||||
return a;
|
||||
});
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
sm.def("index_using_ellipsis", [](py::array a) {
|
||||
return a[py::make_tuple(0, py::ellipsis(), 0)];
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user