Systematically change most py::class_ to py::classh under docs/

This commit is contained in:
Ralf W. Grosse-Kunstleve
2025-02-24 12:10:38 -08:00
parent 449ccebc8a
commit ac9d31e13f
8 changed files with 116 additions and 137 deletions

View File

@@ -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;