22#include "pybind11/pybind11.h"
25#include "ndarray/pybind11.h"
31using namespace pybind11::literals;
41 using Class = MatrixBuilder<T>;
42 using PyCLass = py::class_<Class, std::shared_ptr<Class>>;
45 return wrappers.
wrapType(PyCLass(wrappers.module, name.c_str()), [](
auto &mod,
auto &cls) {
46 cls.def(py::init<ndarray::Array<T const, 1, 1> const &, ndarray::Array<T const, 1, 1> const &, int>(),
47 "x"_a,
"y"_a,
"order"_a);
48 cls.def(py::init<ndarray::Array<T const, 1, 1> const &, ndarray::Array<T const, 1, 1> const &, int,
49 ShapeletFunction const &>(),
50 "x"_a,
"y"_a,
"order"_a,
"psf"_a);
51 cls.def(py::init<ndarray::Array<T const, 1, 1> const &, ndarray::Array<T const, 1, 1> const &,
52 MultiShapeletBasis const &>(),
53 "x"_a,
"y"_a,
"basis"_a);
54 cls.def(py::init<ndarray::Array<T const, 1, 1> const &, ndarray::Array<T const, 1, 1> const &,
55 MultiShapeletBasis const &, MultiShapeletFunction const &>(),
56 "x"_a,
"y"_a,
"basis"_a,
"psf"_a);
58 cls.def(
"getDataSize", &Class::getDataSize);
59 cls.def(
"getBasisSize", &Class::getBasisSize);
60 cls.def(
"allocateOutput", &Class::allocateOutput);
63 (void (Class::*)(ndarray::Array<T, 2, -1> const &, afw::geom::ellipses::Ellipse const &) const) &
65 cls.def(
"__call__", (ndarray::Array<T, 2, -2> (Class::*)(afw::geom::ellipses::Ellipse const &) const) &
73 using Class = MatrixBuilderWorkspace<T>;
74 using PyClass = py::class_<Class, std::shared_ptr<Class>>;
75 std::string name =
"MatrixBuilderWorkspace" + suffix;
77 return wrappers.
wrapType(
PyClass(wrappers.module, name.c_str()), [](
auto &mod,
auto &cls) {
79 cls.def(py::init<int>(),
"size"_a);
80 cls.def(py::init<Class const &>(),
"other"_a);
82 cls.def(
"getRemaining", &Class::getRemaining);
89 using Class = MatrixBuilderFactory<T>;
90 using PyClass = py::class_<Class, std::shared_ptr<Class>>;
93 return wrappers.
wrapType(
PyClass(wrappers.module, name.c_str()), [](
auto &mod,
auto &cls) {
94 cls.def(py::init<ndarray::Array<T const, 1, 1> const &, ndarray::Array<T const, 1, 1> const &, int>(),
95 "x"_a,
"y"_a,
"order"_a);
96 cls.def(py::init<ndarray::Array<T const, 1, 1> const &, ndarray::Array<T const, 1, 1> const &, int,
97 ShapeletFunction const &>(),
98 "x"_a,
"y"_a,
"order"_a,
"psf"_a);
99 cls.def(py::init<ndarray::Array<T const, 1, 1> const &, ndarray::Array<T const, 1, 1> const &,
100 MultiShapeletBasis const &>(),
101 "x"_a,
"y"_a,
"basis"_a);
102 cls.def(py::init<ndarray::Array<T const, 1, 1> const &, ndarray::Array<T const, 1, 1> const &,
103 MultiShapeletBasis const &, MultiShapeletFunction const &>(),
104 "x"_a,
"y"_a,
"basis"_a,
"psf"_a);
106 cls.def(
"__call__", (MatrixBuilder<T> (Class::*)() const) &Class::operator());
107 cls.def(
"__call__", (MatrixBuilder<T> (Class::*)(typename Class::Workspace &) const) &Class::operator(),
110 cls.def(
"getDataSize", &Class::getDataSize);
111 cls.def(
"getBasisSize", &Class::getBasisSize);
112 cls.def(
"computeWorkspace", &Class::computeWorkspace);
118 auto &mod = wrappers.module;
119 auto clsMatrixBuilder = declareMatrixBuilder<T>(wrappers, suffix);
120 auto clsMatrixBuilderWorkspace = declareMatrixBuilderWorkspace<T>(wrappers, suffix);
121 auto clsMatrixBuilderFactory = declareMatrixBuilderFactory<T>(wrappers, suffix);
123 clsMatrixBuilder.attr(
"Workspace") = clsMatrixBuilderWorkspace;
124 clsMatrixBuilder.attr(
"Factory") = clsMatrixBuilderFactory;
126 clsMatrixBuilderFactory.attr(
"Workspace") = clsMatrixBuilderWorkspace;
127 clsMatrixBuilderFactory.attr(
"Builder") = clsMatrixBuilder;
133 declareMatrixBuilderTemplates<float>(wrappers,
"F");
134 declareMatrixBuilderTemplates<double>(wrappers,
"D");
A helper class for subdividing pybind11 module across multiple translation units (i....
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
py::class_< PixelAreaBoundedField, std::shared_ptr< PixelAreaBoundedField >, BoundedField > PyClass
void wrapMatrixBuilder(WrapperCollection &wrappers)