-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: cannot pass 1d matrix
(numpy shape (1,1)) across nanobind as Eigen::Matrix<double,-1,-1>
#544
Comments
1d matrix
(numpy shape 1,1) across nanobind as Eigen::Matrix<double,-1,-1>
1d matrix
(numpy shape (1,1)) across nanobind as Eigen::Matrix<double,-1,-1>
please change your C++ function argument to I suspect that the ordering of the array is the problem, as Eigen uses a column major format and Numpy a row major format. You can also change the layout in Eigen with Eigen::RowMajor. |
If that is the explanation, then I'm surprised that the Eigen type caster does not make an implicit copy (which is explicitly allowed in this case.) Maybe @WKarel knows? |
Interesting -- that works -- thank you very much! I had thought that the row major vs column major ordering was implicitly handled with a copy where required. This signature also works!
Oddly enough, the original signature (with RowMajor on numpy side and ColMajor on Eigen side) works if you pass at least an ndarray with shape |
I have never really worked on the type_caster for plain Eigen types (but mostly on Ref and Map), and there is surely room for improvement - see also #504 |
Thanks for the report. The issue was unrelated to the Eigen<->nanobind interface and is fixed in a76cfff. |
Problem description
I get a type error when I try to pass a 1d ndarray to c++ function accepting
Eigen::Matrix<double,-1,-1>
(orEigen::Array<double,-1-1>
.Behavior here seems unexpected to me -- I don't know if this might be too hard an issue to be fixable implementation wise ...
Thanks much!
Reproducible example code
c++
python
Error
The text was updated successfully, but these errors were encountered: