mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-11 17:00:34 +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:
@@ -693,6 +693,9 @@ inline bool PyIterable_Check(PyObject *obj) {
|
||||
}
|
||||
|
||||
inline bool PyNone_Check(PyObject *o) { return o == Py_None; }
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
inline bool PyEllipsis_Check(PyObject *o) { return o == Py_Ellipsis; }
|
||||
#endif
|
||||
|
||||
inline bool PyUnicode_Check_Permissive(PyObject *o) { return PyUnicode_Check(o) || PYBIND11_BYTES_CHECK(o); }
|
||||
|
||||
@@ -967,6 +970,14 @@ public:
|
||||
none() : object(Py_None, borrowed_t{}) { }
|
||||
};
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
class ellipsis : public object {
|
||||
public:
|
||||
PYBIND11_OBJECT(ellipsis, object, detail::PyEllipsis_Check)
|
||||
ellipsis() : object(Py_Ellipsis, borrowed_t{}) { }
|
||||
};
|
||||
#endif
|
||||
|
||||
class bool_ : public object {
|
||||
public:
|
||||
PYBIND11_OBJECT_CVT(bool_, object, PyBool_Check, raw_bool)
|
||||
|
||||
Reference in New Issue
Block a user