22#include "pybind11/pybind11.h"
24#include "ndarray/pybind11.h"
30using namespace pybind11::literals;
40 using Class = MatrixBuilder<T>;
42 py::class_<Class, std::shared_ptr<Class>>
cls(mod, (
"MatrixBuilder" + suffix).c_str());
44 cls.def(py::init<ndarray::Array<T const, 1, 1>
const &, ndarray::Array<T const, 1, 1>
const &,
int>(),
45 "x"_a,
"y"_a,
"order"_a);
46 cls.def(py::init<ndarray::Array<T const, 1, 1>
const &, ndarray::Array<T const, 1, 1>
const &,
int,
47 ShapeletFunction
const &>(),
48 "x"_a,
"y"_a,
"order"_a,
"psf"_a);
49 cls.def(py::init<ndarray::Array<T const, 1, 1>
const &, ndarray::Array<T const, 1, 1>
const &,
50 MultiShapeletBasis
const &>(),
51 "x"_a,
"y"_a,
"basis"_a);
52 cls.def(py::init<ndarray::Array<T const, 1, 1>
const &, ndarray::Array<T const, 1, 1>
const &,
53 MultiShapeletBasis
const &, MultiShapeletFunction
const &>(),
54 "x"_a,
"y"_a,
"basis"_a,
"psf"_a);
56 cls.def(
"getDataSize", &Class::getDataSize);
57 cls.def(
"getBasisSize", &Class::getBasisSize);
58 cls.def(
"allocateOutput", &Class::allocateOutput);
61 (
void (Class::*)(ndarray::Array<T, 2, -1>
const &, afw::geom::ellipses::Ellipse
const &)
const) &
63 cls.def(
"__call__", (ndarray::Array<T, 2, -2> (Class::*)(afw::geom::ellipses::Ellipse
const &)
const) &
71declareMatrixBuilderWorkspace(py::module &mod,
std::string const &suffix) {
72 using Class = MatrixBuilderWorkspace<T>;
74 py::class_<Class, std::shared_ptr<Class>>
cls(mod, (
"MatrixBuilderWorkspace" + suffix).c_str());
76 cls.def(py::init<int>(),
"size"_a);
77 cls.def(py::init<Class const &>(),
"other"_a);
79 cls.def(
"getRemaining", &Class::getRemaining);
87 using Class = MatrixBuilderFactory<T>;
89 py::class_<Class, std::shared_ptr<Class>>
cls(mod, (
"MatrixBuilderFactory" + suffix).c_str());
91 cls.def(py::init<ndarray::Array<T const, 1, 1>
const &, ndarray::Array<T const, 1, 1>
const &,
int>(),
92 "x"_a,
"y"_a,
"order"_a);
93 cls.def(py::init<ndarray::Array<T const, 1, 1>
const &, ndarray::Array<T const, 1, 1>
const &,
int,
94 ShapeletFunction
const &>(),
95 "x"_a,
"y"_a,
"order"_a,
"psf"_a);
96 cls.def(py::init<ndarray::Array<T const, 1, 1>
const &, ndarray::Array<T const, 1, 1>
const &,
97 MultiShapeletBasis
const &>(),
98 "x"_a,
"y"_a,
"basis"_a);
99 cls.def(py::init<ndarray::Array<T const, 1, 1>
const &, ndarray::Array<T const, 1, 1>
const &,
100 MultiShapeletBasis
const &, MultiShapeletFunction
const &>(),
101 "x"_a,
"y"_a,
"basis"_a,
"psf"_a);
103 cls.def(
"__call__", (MatrixBuilder<T> (Class::*)()
const) & Class::operator());
104 cls.def(
"__call__", (MatrixBuilder<T> (Class::*)(
typename Class::Workspace &)
const) & Class::operator(),
107 cls.def(
"getDataSize", &Class::getDataSize);
108 cls.def(
"getBasisSize", &Class::getBasisSize);
109 cls.def(
"computeWorkspace", &Class::computeWorkspace);
115void declareMatrixBuilderTemplates(py::module &mod,
std::string const &suffix) {
116 auto clsMatrixBuilder = declareMatrixBuilder<T>(mod, suffix);
117 auto clsMatrixBuilderWorkspace = declareMatrixBuilderWorkspace<T>(mod, suffix);
118 auto clsMatrixBuilderFactory = declareMatrixBuilderFactory<T>(mod, suffix);
120 clsMatrixBuilder.attr(
"Workspace") = clsMatrixBuilderWorkspace;
121 clsMatrixBuilder.attr(
"Factory") = clsMatrixBuilderFactory;
123 clsMatrixBuilderFactory.attr(
"Workspace") = clsMatrixBuilderWorkspace;
124 clsMatrixBuilderFactory.attr(
"Builder") = clsMatrixBuilder;
130 py::module::import(
"lsst.afw.geom");
131 declareMatrixBuilderTemplates<float>(mod,
"F");
132 declareMatrixBuilderTemplates<double>(mod,
"D");
PYBIND11_MODULE(basisEvaluator, mod)