22 #include "pybind11/pybind11.h"
23 #include "pybind11/stl.h"
25 #include "ndarray/pybind11.h"
30 using namespace pybind11::literals;
37 template <
typename PyClass>
38 void declareMultiShapeletFunctionMembers(
PyClass &
cls) {
39 using Class = MultiShapeletFunction;
41 cls.def(py::init<>());
42 cls.def(py::init<Class const &>());
43 cls.def(py::init<typename Class::ComponentList const &>());
44 cls.def(py::init<ShapeletFunction const &>());
46 cls.def(
"getComponents", [](Class
const &
self) {
50 for (
size_t i = 0; i <
components.size(); ++i) {
56 cls.def(
"addComponent",
57 [](Class &
self,
typename Class::Component
const &c) {
self.getComponents().push_back(c); });
58 cls.def(
"normalize", &Class::normalize,
"value"_a = 1.0);
59 cls.def(
"shiftInPlace", &Class::shiftInPlace);
60 cls.def(
"transformInPlace", &Class::transformInPlace);
61 cls.def(
"convolve", (Class (Class::*)(ShapeletFunction
const &)
const) &
Class::convolve);
63 cls.def(
"evaluate", &Class::evaluate);
66 template <
typename PyClass>
67 void declareMultiShapeletFunctionEvaluatorMembers(
PyClass &
cls) {
68 using Class = MultiShapeletFunctionEvaluator;
70 cls.def(py::init<MultiShapeletFunction const &>());
72 cls.def(
"__call__", (
double (Class::*)(
double,
double)
const) & Class::operator());
73 cls.def(
"__call__", (
double (Class::*)(
geom::Point2D const &)
const) & Class::operator());
74 cls.def(
"__call__", (
double (Class::*)(
geom::Extent2D const &)
const) & Class::operator());
76 (ndarray::Array<double, 1, 1> (Class::*)(ndarray::Array<double const, 1>
const &,
77 ndarray::Array<double const, 1>
const &)
const) &
81 (
void (Class::*)(ndarray::Array<double, 2, 1>
const &,
geom::Point2I const &)
const) &
88 cls.def(
"computeMoments", &Class::computeMoments);
89 cls.def(
"update", &Class::update);
95 py::module::import(
"lsst.afw.geom");
96 py::module::import(
"lsst.afw.image");
98 py::class_<MultiShapeletFunction, std::shared_ptr<MultiShapeletFunction>> clsMultiShapeletFunction(
99 mod,
"MultiShapeletFunction");
100 py::class_<MultiShapeletFunctionEvaluator, std::shared_ptr<MultiShapeletFunctionEvaluator>>
101 clsMultiShapeletFunctionEvaluator(mod,
"MultiShapeletFunctionEvaluator");
103 declareMultiShapeletFunctionMembers(clsMultiShapeletFunction);
104 declareMultiShapeletFunctionEvaluatorMembers(clsMultiShapeletFunctionEvaluator);