mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 14:45:12 +00:00
Use new style __init__ in numpy docs (#2316)
This commit is contained in:
parent
96c6763613
commit
441e777040
@ -81,7 +81,7 @@ buffer objects (e.g. a NumPy matrix).
|
|||||||
constexpr bool rowMajor = Matrix::Flags & Eigen::RowMajorBit;
|
constexpr bool rowMajor = Matrix::Flags & Eigen::RowMajorBit;
|
||||||
|
|
||||||
py::class_<Matrix>(m, "Matrix", py::buffer_protocol())
|
py::class_<Matrix>(m, "Matrix", py::buffer_protocol())
|
||||||
.def("__init__", [](Matrix &m, py::buffer b) {
|
.def("__init__", [](py::buffer b) {
|
||||||
typedef Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> Strides;
|
typedef Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> Strides;
|
||||||
|
|
||||||
/* Request a buffer descriptor from Python */
|
/* Request a buffer descriptor from Python */
|
||||||
@ -101,7 +101,7 @@ buffer objects (e.g. a NumPy matrix).
|
|||||||
auto map = Eigen::Map<Matrix, 0, Strides>(
|
auto map = Eigen::Map<Matrix, 0, Strides>(
|
||||||
static_cast<Scalar *>(info.ptr), info.shape[0], info.shape[1], strides);
|
static_cast<Scalar *>(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
|
For reference, the ``def_buffer()`` call for this Eigen data type should look
|
||||||
|
Loading…
Reference in New Issue
Block a user