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
For example, say I have MyCppClass(const Eigen::MatrixXd& arg). How do I bind this so that it can accept an nb::ndarray type instead? It looks like nb::init requires an exact type match.
I can handle the conversions to the types, I'm just not sure how to actually bind this. Especially when I have default values. For example:
.def("__init__",
// Manual constructor wrapper to convert numpy arrays to Eigen::MatrixXd
[](MyType* self,
nb::ndarray<> my_matrix_object) {
// Use defaults if Python args are None
MatrixXd m_mat = numpy_to_eigen(my_matrix_object);
new (self) MyType(m_mat);
},
"my_matrix_object"_a = eigen_to_numpy(MatrixXd::Zero(1, 4))
)
This compiles, but does not recognize that I have a default argument, or something like that. When I try to create MyType() in Python, I get a argument mismatch error.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
For example, say I have
MyCppClass(const Eigen::MatrixXd& arg)
. How do I bind this so that it can accept annb::ndarray
type instead? It looks likenb::init
requires an exact type match.I can handle the conversions to the types, I'm just not sure how to actually bind this. Especially when I have default values. For example:
This compiles, but does not recognize that I have a default argument, or something like that. When I try to create
MyType()
in Python, I get a argument mismatch error.Beta Was this translation helpful? Give feedback.
All reactions