24#include "pybind11/pybind11.h"
26#include "pybind11/eigen.h"
31#include "pybind11/stl.h"
32#include "ndarray/pybind11.h"
40using namespace py::literals;
53 os <<
"[" <<
self.getFromEndpoint().getNAxes() <<
"->" <<
self.getToEndpoint().getNAxes() <<
"]";
57template <
class FromEndpo
int,
class ToEndpo
int,
class NextToEndpo
int,
class PyClass>
58void declareMethodTemplates(
PyClass &cls) {
59 using ThisTransform = Transform<FromEndpoint, ToEndpoint>;
60 using NextTransform = Transform<ToEndpoint, NextToEndpoint>;
61 using SeriesTransform = Transform<FromEndpoint, NextToEndpoint>;
65 ThisTransform::template then<NextToEndpoint>,
66 "next"_a,
"simplify"_a =
true);
72template <
class FromEndpo
int,
class ToEndpo
int>
73void declareTransform(lsst::utils::python::WrapperCollection &wrappers) {
74 using Class = Transform<FromEndpoint, ToEndpoint>;
75 using ToPoint =
typename ToEndpoint::Point;
76 using ToArray =
typename ToEndpoint::Array;
77 using FromPoint =
typename FromEndpoint::Point;
78 using FromArray =
typename FromEndpoint::Array;
80 std::string const pyClassName = Class::getShortClassName();
83 [](
auto &mod,
auto &cls) {
84 std::string const pyClassName = Class::getShortClassName();
85 cls.def(py::init<ast::FrameSet const &, bool>(),
"frameSet"_a,
"simplify"_a = true);
86 cls.def(py::init<ast::Mapping const &, bool>(),
"mapping"_a,
"simplify"_a = true);
88 cls.def_property_readonly(
"hasForward", &Class::hasForward);
89 cls.def_property_readonly(
"hasInverse", &Class::hasInverse);
90 cls.def_property_readonly(
"fromEndpoint", &Class::getFromEndpoint);
91 cls.def_property_readonly(
"toEndpoint", &Class::getToEndpoint);
95 cls.def(
"getMapping", [](Class const &self) { return self.getMapping()->copy(); });
97 cls.def(
"applyForward",
98 py::overload_cast<FromArray const &>(&Class::applyForward, py::const_),
"array"_a);
99 cls.def(
"applyForward",
100 py::overload_cast<FromPoint const &>(&Class::applyForward, py::const_),
"point"_a);
101 cls.def(
"applyInverse", py::overload_cast<ToArray const &>(&Class::applyInverse, py::const_),
103 cls.def(
"applyInverse", py::overload_cast<ToPoint const &>(&Class::applyInverse, py::const_),
105 cls.def(
"inverted", &Class::inverted);
112 cls.def_static(
"readString", &Class::readString);
113 cls.def(
"writeString", &Class::writeString);
115 declareMethodTemplates<FromEndpoint, ToEndpoint, GenericEndpoint>(cls);
116 declareMethodTemplates<FromEndpoint, ToEndpoint, Point2Endpoint>(cls);
117 declareMethodTemplates<FromEndpoint, ToEndpoint, SpherePointEndpoint>(cls);
120 cls.def(
"__str__", [pyClassName](Class
const &
self) {
return formatStr(
self, pyClassName); });
122 cls.def(
"__repr__", [pyClassName](Class
const &
self) {
123 return "lsst.afw.geom." + formatStr(
self, pyClassName);
126 table::io::python::addPersistableMethods<Class>(cls);
131 wrappers.addSignatureDependency(
"lsst.afw.table.io");
132 wrappers.addSignatureDependency(
"astshim");
133 declareTransform<GenericEndpoint, GenericEndpoint>(wrappers);
134 declareTransform<GenericEndpoint, Point2Endpoint>(wrappers);
135 declareTransform<GenericEndpoint, SpherePointEndpoint>(wrappers);
136 declareTransform<Point2Endpoint, GenericEndpoint>(wrappers);
137 declareTransform<Point2Endpoint, Point2Endpoint>(wrappers);
138 declareTransform<Point2Endpoint, SpherePointEndpoint>(wrappers);
139 declareTransform<SpherePointEndpoint, GenericEndpoint>(wrappers);
140 declareTransform<SpherePointEndpoint, Point2Endpoint>(wrappers);
141 declareTransform<SpherePointEndpoint, SpherePointEndpoint>(wrappers);
void wrapTransform(lsst::utils::python::WrapperCollection &)
py::class_< PixelAreaBoundedField, std::shared_ptr< PixelAreaBoundedField >, BoundedField > PyClass
A base class for image defects.