lsst.utils  13.0-8-gb7ca535+4
python.cc
Go to the documentation of this file.
1 #include "pybind11/pybind11.h"
2 #include "pybind11/stl.h"
3 
4 #include <utility>
5 
6 #include "lsst/utils/python.h"
7 
8 namespace py = pybind11;
9 using namespace pybind11::literals;
10 
11 namespace lsst {
12 namespace utils {
13 namespace python {
14 
15 PYBIND11_PLUGIN(python) {
16  py::module mod("python");
17 
18  // wrap cppIndex in order to make it easy to test
19  mod.def("cppIndex", (std::size_t(*)(std::ptrdiff_t, std::ptrdiff_t))cppIndex, "size"_a, "i"_a);
20  mod.def("cppIndex", (std::pair<std::size_t, std::size_t>(*)(std::ptrdiff_t, std::ptrdiff_t,
21  std::ptrdiff_t, std::ptrdiff_t))cppIndex,
22  "size_i"_a, "size_j"_a, "i"_a, "j"_a);
23 
24  return mod.ptr();
25 }
26 
27 } // python
28 } // utils
29 } // lsst
std::size_t cppIndex(std::ptrdiff_t size, std::ptrdiff_t i)
Compute a C++ index from a Python index (negative values count from the end) and range-check.
Definition: python.h:79
Definition: main.dox:1
PYBIND11_PLUGIN(python)
Definition: python.cc:15