| 113 | |
| 114 | template <typename T> |
| 115 | T checked_cast(const py::handle &h, const std::string &vector_field, |
| 116 | const std::string &expected_type) { |
| 117 | try { |
| 118 | return py::cast<T>(h); |
| 119 | } catch (const py::cast_error &e) { |
| 120 | std::string actual_type = std::string(py::str(py::type::of(h))); |
| 121 | std::string msg = |
| 122 | vector_field + ": expected " + expected_type + ", got " + actual_type; |
| 123 | throw py::type_error(msg); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | template <typename ValueType, typename ValueCastFn> |
| 128 | std::pair<std::string, std::string> serialize_sparse_vector( |
nothing calls this directly
no outgoing calls
no test coverage detected