24 #include "pybind11/pybind11.h"
25 #include "pybind11/stl.h"
35 using namespace pybind11::literals;
41 using utils::python::WrapperCollection;
46 template <
typename Catalog1,
typename Catalog2>
48 typedef typename Catalog1::Record Record1;
49 typedef typename Catalog2::Record Record2;
52 using Class = Match<Record1, Record2>;
53 using PyClass = py::class_<Class, std::shared_ptr<Class>>;
54 wrappers.wrapType(
PyClass(wrappers.module, (
prefix +
"Match").c_str()), [](
auto &mod,
auto &
cls) {
55 cls.def(py::init<>());
56 cls.def(py::init<std::shared_ptr<Record1> const &, std::shared_ptr<Record2> const &, double>(),
57 "first"_a,
"second"_a,
"distance"_a);
60 cls.def_readwrite(
"first", &Match<Record1, Record2>::first);
61 cls.def_readwrite(
"second", &Match<Record1, Record2>::second);
62 cls.def_readwrite(
"distance", &Match<Record1, Record2>::distance);
66 wrappers.wrap([](
auto &mod) {
67 mod.def(
"unpackMatches", &unpackMatches<Catalog1, Catalog2>,
"matches"_a,
"cat1"_a,
"cat2"_a);
71 MatchControl
const &))matchRaDec<Catalog1, Catalog2>,
72 "cat1"_a,
"cat2"_a,
"radius"_a,
"mc"_a = MatchControl());
77 template <
typename Catalog>
78 void declareMatch1(WrapperCollection &wrappers) {
80 wrappers.wrap([](
auto &mod) {
82 (MatchList(*)(Catalog
const &,
lsst::geom::Angle, MatchControl
const &))matchRaDec<Catalog>,
83 "cat"_a,
"radius"_a,
"mc"_a = MatchControl());
90 wrappers.
wrapType(py::class_<MatchControl>(wrappers.
module,
"MatchControl"), [](
auto &mod,
auto &
cls) {
91 cls.def(py::init<>());
92 LSST_DECLARE_CONTROL_FIELD(cls, MatchControl, findOnlyClosest);
93 LSST_DECLARE_CONTROL_FIELD(cls, MatchControl, symmetricMatch);
94 LSST_DECLARE_CONTROL_FIELD(cls, MatchControl, includeMismatches);
97 declareMatch2<SimpleCatalog, SimpleCatalog>(wrappers,
"Simple");
98 declareMatch2<SimpleCatalog, SourceCatalog>(wrappers,
"Reference");
99 declareMatch2<SourceCatalog, SourceCatalog>(wrappers,
"Source");
100 declareMatch1<SimpleCatalog>(wrappers);
101 declareMatch1<SourceCatalog>(wrappers);
103 wrappers.
wrap([](
auto &mod) {
107 "cat1"_a,
"cat2"_a,
"radius"_a,
"mc"_a =
MatchControl());