Skip to content

Commit 441e777

Browse files
authored
Use new style __init__ in numpy docs (#2316)
1 parent 96c6763 commit 441e777

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/advanced/pycpp/numpy.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ buffer objects (e.g. a NumPy matrix).
8181
constexpr bool rowMajor = Matrix::Flags & Eigen::RowMajorBit;
8282
8383
py::class_<Matrix>(m, "Matrix", py::buffer_protocol())
84-
.def("__init__", [](Matrix &m, py::buffer b) {
84+
.def("__init__", [](py::buffer b) {
8585
typedef Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> Strides;
8686
8787
/* Request a buffer descriptor from Python */
@@ -101,7 +101,7 @@ buffer objects (e.g. a NumPy matrix).
101101
auto map = Eigen::Map<Matrix, 0, Strides>(
102102
static_cast<Scalar *>(info.ptr), info.shape[0], info.shape[1], strides);
103103
104-
new (&m) Matrix(map);
104+
return Matrix(m);
105105
});
106106
107107
For reference, the ``def_buffer()`` call for this Eigen data type should look

0 commit comments

Comments
 (0)