From 4493751a5f8c74b63e64088594e2d59af2f84639 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sun, 23 Aug 2020 18:35:51 +0200 Subject: [PATCH] Fix new-style __init__ usage in numpy docs (#2426) --- docs/advanced/pycpp/numpy.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/advanced/pycpp/numpy.rst b/docs/advanced/pycpp/numpy.rst index 39cfa7365..8e5c6092c 100644 --- a/docs/advanced/pycpp/numpy.rst +++ b/docs/advanced/pycpp/numpy.rst @@ -81,7 +81,7 @@ buffer objects (e.g. a NumPy matrix). constexpr bool rowMajor = Matrix::Flags & Eigen::RowMajorBit; py::class_(m, "Matrix", py::buffer_protocol()) - .def("__init__", [](py::buffer b) { + .def(py::init([](py::buffer b) { typedef Eigen::Stride Strides; /* Request a buffer descriptor from Python */ @@ -101,8 +101,8 @@ buffer objects (e.g. a NumPy matrix). auto map = Eigen::Map( static_cast(info.ptr), info.shape[0], info.shape[1], strides); - return Matrix(m); - }); + return Matrix(map); + })); For reference, the ``def_buffer()`` call for this Eigen data type should look as follows: