MCPcopy Create free account
hub / github.com/alibaba/zvec / checked_cast

Function checked_cast

src/binding/python/model/param/python_param.cc:115–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113
114template <typename T>
115T 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
127template <typename ValueType, typename ValueCastFn>
128std::pair<std::string, std::string> serialize_sparse_vector(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected