From 0968547d1d023af2944569208679e5e40d326f2a Mon Sep 17 00:00:00 2001 From: Boris Staletic Date: Thu, 23 Jul 2020 05:23:59 +0200 Subject: [PATCH] Use new style __init__ in numpy docs --- docs/advanced/pycpp/numpy.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/advanced/pycpp/numpy.rst b/docs/advanced/pycpp/numpy.rst index aef7abe3d7..f1941392fa 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__", [](Matrix &m, py::buffer b) { + .def("__init__", [](py::buffer b) { typedef Eigen::Stride Strides; /* Request a buffer descriptor from Python */ @@ -101,7 +101,7 @@ buffer objects (e.g. a NumPy matrix). auto map = Eigen::Map( static_cast(info.ptr), info.shape[0], info.shape[1], strides); - new (&m) Matrix(map); + return Matrix(m); }); For reference, the ``def_buffer()`` call for this Eigen data type should look