22#include "pybind11/pybind11.h"
24#include "pybind11/stl.h"
28#include "ndarray/pybind11.h"
35using namespace pybind11::literals;
44 using PyPolynomialTransform = py::class_<PolynomialTransform, std::shared_ptr<PolynomialTransform>>;
46 wrappers.
wrapType(PyPolynomialTransform(wrappers.module,
"PolynomialTransform"), [](
auto &mod,
auto &cls) {
47 cls.def(py::init<ndarray::Array<double const, 2, 0> const &,
48 ndarray::Array<double const, 2, 0> const &>(),
49 "xCoeffs"_a,
"yCoeffs"_a);
50 cls.def(py::init<PolynomialTransform const &>(),
"other"_a);
52 cls.def_static(
"convert",
53 (PolynomialTransform(*)(ScaledPolynomialTransform const &)) &PolynomialTransform::convert,
55 cls.def_static(
"convert",
56 (PolynomialTransform(*)(SipForwardTransform const &)) &PolynomialTransform::convert,
58 cls.def_static(
"convert",
59 (PolynomialTransform(*)(SipReverseTransform const &)) &PolynomialTransform::convert,
62 cls.def(
"__call__", &PolynomialTransform::operator(),
"in"_a);
64 cls.def(
"getOrder", &PolynomialTransform::getOrder);
65 cls.def(
"getXCoeffs", &PolynomialTransform::getXCoeffs);
66 cls.def(
"getYCoeffs", &PolynomialTransform::getYCoeffs);
67 cls.def(
"linearize", &PolynomialTransform::linearize);
72 using PyClass = py::class_<ScaledPolynomialTransform, std::shared_ptr<ScaledPolynomialTransform>>;
74 wrappers.
wrapType(
PyClass(wrappers.module,
"ScaledPolynomialTransform"), [](
auto &mod,
auto &cls) {
75 cls.def(py::init<PolynomialTransform const &, geom::AffineTransform const &,
76 geom::AffineTransform const &>(),
77 "poly"_a,
"inputScaling"_a,
"outputScalingInverse"_a);
78 cls.def(py::init<ScaledPolynomialTransform const &>(),
"other"_a);
82 (ScaledPolynomialTransform(*)(PolynomialTransform const &)) &ScaledPolynomialTransform::convert,
86 (ScaledPolynomialTransform(*)(SipForwardTransform const &)) &ScaledPolynomialTransform::convert,
90 (ScaledPolynomialTransform(*)(SipReverseTransform const &)) &ScaledPolynomialTransform::convert,
93 cls.def(
"__call__", &ScaledPolynomialTransform::operator(),
"in"_a);
95 cls.def(
"getPoly", &ScaledPolynomialTransform::getPoly, py::return_value_policy::reference_internal);
96 cls.def(
"getInputScaling", &ScaledPolynomialTransform::getInputScaling,
97 py::return_value_policy::reference_internal);
98 cls.def(
"getOutputScalingInverse", &ScaledPolynomialTransform::getOutputScalingInverse,
99 py::return_value_policy::reference_internal);
100 cls.def(
"linearize", &ScaledPolynomialTransform::linearize);
107 declarePolynomialTransform(wrappers);
108 declareScaledPolynomialTransform(wrappers);
110 wrappers.module.def(
"compose",
113 wrappers.module.def(
"compose",
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
PolynomialTransform compose(geom::AffineTransform const &t1, PolynomialTransform const &t2)
Return a PolynomialTransform that is equivalent to the composition t1(t2())
void wrapPolynomialTransform(WrapperCollection &wrappers)