23 #ifndef LSST_SPHGEOM_PYTHON_UTILS_H_
24 #define LSST_SPHGEOM_PYTHON_UTILS_H_
26 #include "pybind11/pybind11.h"
41 ptrdiff_t convertIndex(ptrdiff_t len, pybind11::int_ i) {
42 auto j =
static_cast<ptrdiff_t
>(i);
43 if ((j == -1 && PyErr_Occurred()) || j < -len || j >= len) {
45 throw pybind11::index_error(
46 pybind11::str(
"Index {} not in range({}, {})")
47 .format(i, -len, len));
49 return (j < 0) ? j + len : j;
54 pybind11::bytes encode(Region
const &
self) {
55 std::vector<uint8_t> bytes =
self.encode();
56 return pybind11::bytes(
reinterpret_cast<char const *
>(bytes.data()),
65 #endif // LSST_SPHGEOM_PYTHON_UTILS_H_