24 #ifndef LSST_UTILS_PYTHON_H 25 #define LSST_UTILS_PYTHON_H 27 #include "pybind11/pybind11.h" 57 template<
typename T,
typename PyClass>
61 pybind11::is_operator());
64 pybind11::is_operator());
80 auto const i_orig = i;
85 if (i < 0 || i >= size) {
87 os <<
"Index " << i_orig <<
" not in range [" << -size <<
", " << size - 1 <<
"]";
88 throw pybind11::index_error(os.
str());
111 os <<
"Index (" << i <<
", " << j <<
") not in range [" 112 << -size_i <<
", " << size_i - 1 <<
"], [" 113 << -size_j <<
", " << size_j - 1 <<
"]";
114 throw pybind11::index_error(os.
str());
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.
void addSharedPtrEquality(PyClass &cls)
Add __eq__ and __ne__ methods based on two std::shared_ptr<T> pointing to the same address...