1#ifndef AFW_TABLE_PYBIND11_SORTEDCATALOG_H_INCLUDED
2#define AFW_TABLE_PYBIND11_SORTEDCATALOG_H_INCLUDED
26#include "pybind11/pybind11.h"
28#include "lsst/utils/python.h"
38template <
typename Record>
56template <
typename Record>
60 using namespace pybind11::literals;
63 using Table =
typename Record::Table;
65 auto clsBase = declareCatalog<Record>(wrappers,
name,
true);
69 fullName =
"_" +
name +
"SortedCatalogBase";
71 fullName =
name +
"Catalog";
76 return wrappers.wrapType(
78 [clsBase](
auto &mod,
auto &cls) {
80 cls.def(pybind11::init<Schema const &>());
81 cls.def(pybind11::init<std::shared_ptr<Table> const &>(),
82 "table"_a = std::shared_ptr<Table>());
83 cls.def(pybind11::init<Catalog const &>());
86 cls.def_static(
"readFits", (Catalog(*)(std::string const &, int, int)) & Catalog::readFits,
87 "filename"_a,
"hdu"_a = fits::DEFAULT_HDU,
"flags"_a = 0);
88 cls.def_static(
"readFits", (Catalog(*)(fits::MemFileManager &, int, int)) & Catalog::readFits,
89 "manager"_a,
"hdu"_a = fits::DEFAULT_HDU,
"flags"_a = 0);
93 (Catalog(Catalog::*)(ndarray::Array<bool const, 1> const &) const) & Catalog::subset);
95 (Catalog(Catalog::*)(std::ptrdiff_t, std::ptrdiff_t, std::ptrdiff_t) const) &
103 [clsBase](py::object const &self, py::object key) -> py::object {
104 if (key.is(py::none())) {
105 key = self.attr(
"table").attr(
"getIdKey")();
107 return clsBase.attr(
"isSorted")(self, key);
109 "key"_a = py::none());
112 if (key.is(py::none())) {
113 key = self.attr(
"table").attr(
"getIdKey")();
115 return clsBase.attr(
"sort")(self, key);
117 "key"_a = py::none());
121 if (key.is(py::none())) {
122 key = self.attr(
"table").attr(
"getIdKey")();
124 return clsBase.attr(
"find")(self, value, key);
126 "value"_a,
"key"_a = py::none());
table::Key< std::string > name
table::Key< std::string > object
Custom catalog class for record/table subclasses that are guaranteed to have an ID,...
PySortedCatalog< Record > declareSortedCatalog(utils::python::WrapperCollection &wrappers, std::string const &name, bool isBase=false)
Wrap an instantiation of lsst::afw::table::SortedCatalogT<Record>.
pybind11::class_< SortedCatalogT< Record >, std::shared_ptr< SortedCatalogT< Record > >, CatalogT< Record > > PySortedCatalog