mirror of
https://github.com/pybind/pybind11.git
synced 2026-06-07 00:04:42 +00:00
Systematically change most py::class_ to py::classh under docs/
This commit is contained in:
@@ -33,7 +33,7 @@ completely avoid copy operations with Python expressions like
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
py::class_<Matrix>(m, "Matrix", py::buffer_protocol())
|
||||
py::classh<Matrix>(m, "Matrix", py::buffer_protocol())
|
||||
.def_buffer([](Matrix &m) -> py::buffer_info {
|
||||
return py::buffer_info(
|
||||
m.data(), /* Pointer to buffer */
|
||||
@@ -47,7 +47,7 @@ completely avoid copy operations with Python expressions like
|
||||
});
|
||||
|
||||
Supporting the buffer protocol in a new type involves specifying the special
|
||||
``py::buffer_protocol()`` tag in the ``py::class_`` constructor and calling the
|
||||
``py::buffer_protocol()`` tag in the ``py::classh`` constructor and calling the
|
||||
``def_buffer()`` method with a lambda function that creates a
|
||||
``py::buffer_info`` description record on demand describing a given matrix
|
||||
instance. The contents of ``py::buffer_info`` mirror the Python buffer protocol
|
||||
@@ -80,7 +80,7 @@ buffer objects (e.g. a NumPy matrix).
|
||||
typedef Matrix::Scalar Scalar;
|
||||
constexpr bool rowMajor = Matrix::Flags & Eigen::RowMajorBit;
|
||||
|
||||
py::class_<Matrix>(m, "Matrix", py::buffer_protocol())
|
||||
py::classh<Matrix>(m, "Matrix", py::buffer_protocol())
|
||||
.def(py::init([](py::buffer b) {
|
||||
typedef Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> Strides;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user