| 32 | } |
| 33 | |
| 34 | py::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 | |
| 58 | py::UniqueObj CTModelObject::getPriorCov() const |
| 59 | { |
nothing calls this directly
no test coverage detected