MCPcopy Create free account
hub / github.com/bab2min/tomotopy / transformMisc

Function transformMisc

src/python/handler/py_LDA.cpp:12–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10using namespace std;
11
12inline tomoto::RawDoc::MiscType transformMisc(const tomoto::RawDoc::MiscType& misc, PyObject* transform)
13{
14 if (!transform || transform == Py_None) return misc;
15 py::UniqueObj args{ py::buildPyValue(misc) };
16 py::UniqueObj res{ PyObject_CallFunctionObjArgs(transform, args.get(), nullptr) };
17 if (!res) throw py::ExcPropagation{};
18 tomoto::RawDoc::MiscType ret;
19 if (!py::toCpp(res.get(), ret))
20 {
21 throw py::ValueError{ "`transform` must return an instance of `dict`." };
22 }
23 return ret;
24}
25
26tomoto::RawDoc::MiscType LDAModelObject::convertMisc(const tomoto::RawDoc::MiscType& o) const
27{

Callers 2

insertCorpusMethod · 0.85
makeCorpusMethod · 0.85

Calls 3

toCppFunction · 0.85
buildPyValueFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected