Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion pyEXP/BasisWrappers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,29 @@ void BasisFactoryClasses(py::module &m)
Returns
-------
None
)", py::arg("coefs"));
)", py::arg("coefs"))
.def("get_shared_ptr_capsule", [](const std::shared_ptr<BasisClasses::BiorthBasis> &self) -> py::capsule {
return py::capsule(
new std::shared_ptr(self),
"BiorthBasis_shared_ptr",
[](void *v) { delete static_cast<std::shared_ptr<BasisClasses::BiorthBasis> *>(v); }
);
},
R"(
Get a capsule containing a shared pointer to the BiorthBasis instance.

Returns
-------
capsule: PyCapsule
A PyCapsule containing a shared pointer to the BiorthBasis instance with
the name "BiorthBasis_shared_ptr".

Notes
-----
This can be used to pass the BiorthBasis instance to non-Pybind11 C extensions
in a lifetime-safe manner.
)"
);

py::class_<BasisClasses::Cylindrical, std::shared_ptr<BasisClasses::Cylindrical>, PyCylindrical, BasisClasses::BiorthBasis>(m, "Cylindrical")
.def(py::init<const std::string&>(),
Expand Down
24 changes: 23 additions & 1 deletion pyEXP/CoefWrappers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,29 @@ void CoefficientClasses(py::module &m) {
--------
addcoef : add coefficient structures to an existing coefficieint container
)",
py::arg("coef"), py::arg("name")="");
py::arg("coef"), py::arg("name")="")
.def("get_shared_ptr_capsule", [](const std::shared_ptr<CoefClasses::Coefs> &self) -> py::capsule {
return py::capsule(
new std::shared_ptr(self),
"Coefs_shared_ptr",
[](void *v) { delete static_cast<std::shared_ptr<CoefClasses::Coefs> *>(v); }
);
},
R"(
Get a capsule containing a shared pointer to the Coefs instance.

Returns
-------
capsule: PyCapsule
A PyCapsule containing a shared pointer to the Coefs instance with
the name "Coefs_shared_ptr".

Notes
-----
This can be used to pass the Coefs instance to non-Pybind11 C extensions
in a lifetime-safe manner.
)"
);

py::class_<CoefClasses::SphCoefs, std::shared_ptr<CoefClasses::SphCoefs>, PySphCoefs, CoefClasses::Coefs>
(m, "SphCoefs", "Container for spherical coefficients")
Expand Down