22 #include "pybind11/pybind11.h"
23 #include "pybind11/stl.h"
29 using namespace py::literals;
33 namespace cameraGeom {
38 using PyDetectorCollectionBase = py::class_<DetectorCollectionBase<T>,
41 using PyDetectorCollection = py::class_<DetectorCollection, DetectorCollectionBase<Detector const>,
45 void declareDetectorCollectionBase(PyDetectorCollectionBase<T> &
cls) {
46 cls.def(
"getNameMap", &DetectorCollectionBase<T>::getNameMap);
47 cls.def(
"getIdMap", &DetectorCollectionBase<T>::getIdMap);
48 cls.def(
"__len__", &DetectorCollectionBase<T>::size);
52 &DetectorCollectionBase<T>::get, py::const_
54 "name"_a,
"default"_a=
nullptr
59 &DetectorCollectionBase<T>::get, py::const_
61 "id"_a,
"default"_a=
nullptr
66 return self.get(
name) !=
nullptr;
71 [](DetectorCollectionBase<T>
const &
self,
int id) {
72 return self.get(
id) !=
nullptr;
77 void declareDetectorCollection(
py::module & mod) {
78 PyDetectorCollectionBase<Detector const>
base(mod,
"DetectorCollectionDetectorBase");
79 declareDetectorCollectionBase(
base);
80 PyDetectorCollection
cls(mod,
"DetectorCollection");
81 cls.def(py::init<DetectorCollection::List>());
82 cls.def(
"getFpBBox", &DetectorCollection::getFpBBox);
87 py::module::import(
"lsst.afw.cameraGeom.detector");
88 declareDetectorCollection(mod);
90 PyDetectorCollectionBase<Detector::InCameraBuilder> cameraBuilderBase(
92 "DetectorCollectionBuilderBase"
94 declareDetectorCollectionBase(cameraBuilderBase);