Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
4493751a
Unverified
Commit
4493751a
authored
Aug 23, 2020
by
Yannick Jadoul
Committed by
GitHub
Aug 23, 2020
Browse files
Fix new-style __init__ usage in numpy docs (#2426)
parent
b8863698
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
docs/advanced/pycpp/numpy.rst
docs/advanced/pycpp/numpy.rst
+3
-3
No files found.
docs/advanced/pycpp/numpy.rst
View file @
4493751a
...
@@ -81,7 +81,7 @@ buffer objects (e.g. a NumPy matrix).
...
@@ -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__",
[](py::buffer b) {
.def(
py::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,8 +101,8 @@ buffer objects (e.g. a NumPy matrix).
...
@@ -101,8 +101,8 @@ 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);
return Matrix(m);
return Matrix(m
ap
);
});
})
)
;
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
as follows:
as follows:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment