You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When returning an Eigen vector to numpy, [...] if it is a compile-time vector–that is, the type has either the number of rows or columns set to 1 at compile time–pybind11 converts to a 1D numpy array when returning the value. [...]
Makes total sense. However, looking at the docstrings:
For m.double_col, the input type makes sense, because that matters to C++ (as mentioned in the docs).
However, the return type is a bit misleading: it states that the output types is numpy.ndarray[numpy.float32[m, 1]].
This is a bit misleading, because the return type's shape is actually (m,).
Additionally, when the return type has
This bit us in RobotLocomotion/drake#13885.
The docs do have a suggested workaround, which is what we'll do, but it'd be nice if the annotation were a bit more truthful.
Reproducible example code
See aforementioned example.
Possible solutions
Somehow distinguish the type string based on return-type? (that could be down by "rerouting" the return type somehow?)
Discard shape information (at the cost of sacrificing info in the argument - probably a non-starter)
As-is
Other?
The text was updated successfully, but these errors were encountered:
FWIW The main "jarring" aspect is that the shape of float[m, n] is truly (m, n), while the shape of float[m, 1] is (m,) (as seen by Python), so it'd be nice to somehow collapse that.
Issue description
Per docs here (as of 2.5.0):
https://pybind11.readthedocs.io/en/stable/advanced/cast/eigen.html#vectors-versus-column-row-matrices
Makes total sense. However, looking at the docstrings:
pybind11/tests/test_eigen.py
Lines 609 to 623 in 4d9024e
For
m.double_col
, the input type makes sense, because that matters to C++ (as mentioned in the docs).However, the return type is a bit misleading: it states that the output types is
numpy.ndarray[numpy.float32[m, 1]]
.This is a bit misleading, because the return type's shape is actually
(m,)
.Additionally, when the return type has
This bit us in RobotLocomotion/drake#13885.
The docs do have a suggested workaround, which is what we'll do, but it'd be nice if the annotation were a bit more truthful.
Reproducible example code
See aforementioned example.
Possible solutions
The text was updated successfully, but these errors were encountered: