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

Method getCorrelations

src/python/handler/py_CT.cpp:34–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34py::UniqueObj CTModelObject::getCorrelations(PyObject* topicId) const
35{
36 auto* inst = getInst<tomoto::ICTModel>();
37 if (!topicId || topicId == Py_None)
38 {
39 float* ptr;
40 auto ret = py::newEmptyArray(ptr, 2, inst->getK(), inst->getK());
41 for (size_t i = 0; i < inst->getK(); ++i)
42 {
43 auto l = inst->getCorrelationTopic(i);
44 memcpy(ptr + i * inst->getK(), l.data(), sizeof(float) * inst->getK());
45 }
46 return ret;
47 }
48
49 size_t topicIdVal;
50 if (!py::toCpp(topicId, topicIdVal))
51 {
52 throw py::ValueError{ "`topic_id` must be an integer or None." };
53 }
54 if (topicIdVal >= inst->getK()) throw py::ValueError{ "`topic_id` must be in range [0, `k`)" };
55 return py::buildPyValue(inst->getCorrelationTopic(topicIdVal));
56}
57
58py::UniqueObj CTModelObject::getPriorCov() const
59{

Callers

nothing calls this directly

Calls 6

newEmptyArrayFunction · 0.85
toCppFunction · 0.85
getCorrelationTopicMethod · 0.80
buildPyValueFunction · 0.70
getKMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected