@@ -1370,7 +1370,7 @@ void BasisFactoryClasses(py::module &m)
13701370 __call__ : same as getFields() but provides field labels in a tuple
13711371 )" ,
13721372 py::arg (" x" ), py::arg (" y" ), py::arg (" z" ))
1373- .def (" getAccel" , py::overload_cast<Eigen::VectorXd& , Eigen::VectorXd& , Eigen::VectorXd& >(&BasisClasses::BiorthBasis::getAccel),
1373+ .def (" getAccel" , py::overload_cast<Eigen::Ref< const Eigen:: VectorXd> , Eigen::Ref< const Eigen:: VectorXd> , Eigen::Ref< const Eigen:: VectorXd> >(&BasisClasses::BiorthBasis::getAccel),
13741374 R"(
13751375 Return the acceleration for a given cartesian position
13761376
@@ -1394,7 +1394,7 @@ void BasisFactoryClasses(py::module &m)
13941394 __call__ : same as getFields() but provides field labels in a tuple
13951395 )" ,
13961396 py::arg (" x" ), py::arg (" y" ), py::arg (" z" ))
1397- .def (" getAccel" , py::overload_cast<RowMatrixXd& >(&BasisClasses::BiorthBasis::getAccel),
1397+ .def (" getAccel" , py::overload_cast<Eigen::Ref< const RowMatrixXd> >(&BasisClasses::BiorthBasis::getAccel),
13981398 R"(
13991399 Return the acceleration for an array of cartesian positions
14001400
@@ -1414,7 +1414,7 @@ void BasisFactoryClasses(py::module &m)
14141414 __call__ : same as getFields() but provides field labels in a tuple
14151415 )" ,
14161416 py::arg (" pos" ))
1417- .def (" getAccelArray" , py::overload_cast<Eigen::VectorXd& , Eigen::VectorXd& , Eigen::VectorXd& >(&BasisClasses::BiorthBasis::getAccel),
1417+ .def (" getAccelArray" , py::overload_cast<Eigen::Ref< const Eigen:: VectorXd> , Eigen::Ref< const Eigen:: VectorXd> , Eigen::Ref< const Eigen:: VectorXd> >(&BasisClasses::BiorthBasis::getAccel),
14181418 R"(
14191419 Return the acceleration for a given cartesian position
14201420
@@ -1561,7 +1561,29 @@ void BasisFactoryClasses(py::module &m)
15611561 Returns
15621562 -------
15631563 None
1564- )" , py::arg (" coefs" ));
1564+ )" , py::arg (" coefs" ))
1565+ .def (" get_shared_ptr_capsule" , [](const std::shared_ptr<BasisClasses::BiorthBasis> &self) -> py::capsule {
1566+ return py::capsule (
1567+ new std::shared_ptr (self),
1568+ " BiorthBasis_shared_ptr" ,
1569+ [](void *v) { delete static_cast <std::shared_ptr<BasisClasses::BiorthBasis> *>(v); }
1570+ );
1571+ },
1572+ R"(
1573+ Get a capsule containing a shared pointer to the BiorthBasis instance.
1574+
1575+ Returns
1576+ -------
1577+ capsule: PyCapsule
1578+ A PyCapsule containing a shared pointer to the BiorthBasis instance with
1579+ the name "BiorthBasis_shared_ptr".
1580+
1581+ Notes
1582+ -----
1583+ This can be used to pass the BiorthBasis instance to non-Pybind11 C extensions
1584+ in a lifetime-safe manner.
1585+ )"
1586+ );
15651587
15661588 py::class_<BasisClasses::Cylindrical, std::shared_ptr<BasisClasses::Cylindrical>, PyCylindrical, BasisClasses::BiorthBasis>(m, " Cylindrical" )
15671589 .def (py::init<const std::string&>(),
0 commit comments