Implement sklearn version in PyWrap
This commit is contained in:
parent
82964190f6
commit
4addaefb47
@ -127,10 +127,19 @@ namespace pywrap {
|
|||||||
}
|
}
|
||||||
std::string PyWrap::sklearnVersion()
|
std::string PyWrap::sklearnVersion()
|
||||||
{
|
{
|
||||||
return "1.0";
|
PyObject* sklearnModule = PyImport_ImportModule("sklearn");
|
||||||
// CPyObject data = PyRun_SimpleString("import sklearn;return sklearn.__version__");
|
if (sklearnModule == nullptr) {
|
||||||
// std::string result = PyUnicode_AsUTF8(data);
|
errorAbort("Couldn't import sklearn");
|
||||||
// return result;
|
}
|
||||||
|
PyObject* versionAttr = PyObject_GetAttrString(sklearnModule, "__version__");
|
||||||
|
if (versionAttr == nullptr || !PyUnicode_Check(versionAttr)) {
|
||||||
|
Py_XDECREF(sklearnModule);
|
||||||
|
errorAbort("Couldn't get sklearn version");
|
||||||
|
}
|
||||||
|
std::string result = PyUnicode_AsUTF8(versionAttr);
|
||||||
|
Py_XDECREF(versionAttr);
|
||||||
|
Py_XDECREF(sklearnModule);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
std::string PyWrap::version(const clfId_t id)
|
std::string PyWrap::version(const clfId_t id)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user