1 #ifndef AFW_TABLE_PYBIND11_SORTEDCATALOG_H_INCLUDED 2 #define AFW_TABLE_PYBIND11_SORTEDCATALOG_H_INCLUDED 25 #include "pybind11/pybind11.h" 35 template <
typename Record>
37 pybind11::class_<SortedCatalogT<Record>, std::shared_ptr<SortedCatalogT<Record>>,
CatalogT<Record>>;
52 template <
typename Record>
54 bool isBase =
false) {
55 namespace py = pybind11;
56 using namespace pybind11::literals;
59 using Table =
typename Record::Table;
61 auto clsBase = declareCatalog<Record>(mod,
name,
true);
65 fullName =
"_" + name +
"SortedCatalogBase";
67 fullName = name +
"Catalog";
74 cls.def(pybind11::init<Schema const &>());
75 cls.def(pybind11::init<std::shared_ptr<Table>
const &>(),
"table"_a = std::shared_ptr<Table>());
76 cls.def(pybind11::init<Catalog const &>());
79 cls.def_static(
"readFits", (
Catalog(*)(std::string
const &,
int,
int)) & Catalog::readFits,
"filename"_a,
80 "hdu"_a = INT_MIN,
"flags"_a = 0);
82 "manager"_a,
"hdu"_a = INT_MIN,
"flags"_a = 0);
85 cls.def(
"subset", (
Catalog (
Catalog::*)(ndarray::Array<bool const, 1>
const &)
const) & Catalog::subset);
87 (
Catalog (
Catalog::*)(std::ptrdiff_t, std::ptrdiff_t, std::ptrdiff_t)
const) & Catalog::subset);
94 [clsBase](py::object
const &
self, py::object key) -> py::object {
95 if (key == py::none()) {
96 key =
self.attr(
"table").attr(
"getIdKey")();
98 return clsBase.attr(
"isSorted")(
self, key);
100 "key"_a = py::none());
102 [clsBase](py::object
const &
self, py::object key) -> py::object {
103 if (key == py::none()) {
104 key =
self.attr(
"table").attr(
"getIdKey")();
106 return clsBase.attr(
"sort")(
self, key);
108 "key"_a = py::none());
110 [clsBase](py::object
const &
self, py::object
const &value, py::object key) -> py::object {
111 if (key == py::none()) {
112 key =
self.attr(
"table").attr(
"getIdKey")();
114 return clsBase.attr(
"find")(
self, value, key);
116 "value"_a,
"key"_a = py::none());
125 #endif // !AFW_TABLE_PYBIND11_CATALOG_H_INCLUDED table::Key< std::string > name
A custom container class for records, based on std::vector.
A base class for image defects.
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
Lifetime-management for memory that goes into FITS memory files.
PySortedCatalog< Record > declareSortedCatalog(pybind11::module &mod, 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