17 #pragma GCC diagnostic ignored "-Wunused-parameter"
18 #pragma GCC diagnostic ignored "-Wunused-function"
20 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
21 #include <numpy/arrayobject.h>
45 Types::EMVA methodType,
49 TDirectory *theBaseDir):
MethodBase(jobName, methodType, methodTitle, dsi, theOption, theBaseDir),
52 if (!PyIsInitialized()) {
93 fMain = PyImport_AddModule(
"__main__");
95 Log <<
kFATAL <<
"Can't import __main__" <<
Endl;
101 Log <<
kFATAL <<
"Can't init global namespace" <<
Endl;
107 Log <<
kFATAL <<
"Can't init local namespace" <<
Endl;
111 #if PY_MAJOR_VERSION < 3
113 PyObject *bName = PyUnicode_FromString(
"__builtin__");
117 Log <<
kFATAL <<
"Can't import __builtin__" <<
Endl;
122 PyObject *bName = PyUnicode_FromString(
"builtins");
126 Log <<
kFATAL <<
"Can't import builtins" <<
Endl;
132 fEval = PyDict_GetItemString(mDict,
"eval");
133 fOpen = PyDict_GetItemString(mDict,
"open");
138 PyObject *pName = PyUnicode_FromString(
"pickle");
142 Log <<
kFATAL <<
"Can't import pickle" <<
Endl;
167 #if PY_MAJOR_VERSION < 3
168 Py_SetProgramName(const_cast<char*>(name.
Data()));
170 Py_SetProgramName((
wchar_t *)name.
Data());
181 if (!Py_IsInitialized())
return kFALSE;
192 PyObject *file_arg = Py_BuildValue(
"(ss)", path.
Data(),
"wb");
194 PyObject *model_arg = Py_BuildValue(
"(OO)", obj,file);
199 Py_DECREF(model_arg);
200 Py_DECREF(model_data);
205 PyObject *file_arg = Py_BuildValue(
"(ss)", path.
Data(),
"rb");
208 PyObject *model_arg = Py_BuildValue(
"(O)", file);
213 Py_DECREF(model_arg);
MsgLogger & Endl(MsgLogger &ml)
static PyObject * fModulePickle
static PyObject * fModuleBuiltin
static void Serialize(TString file, PyObject *classifier)
static int PyIsInitialized()
static void PyInitialize()
const char * Data() const
static PyObject * Eval(TString code)
PyMethodBase(const TString &jobName, Types::EMVA methodType, const TString &methodTitle, DataSetInfo &dsi, const TString &theOption="", TDirectory *theBaseDir=0)
static TString Py_GetProgramName()
static void PySetProgramName(TString name)
static PyObject * fLocalNS
Describe directory structure in memory.
Abstract ClassifierFactory template that handles arbitrary types.
static PyObject * fPickleLoads
static PyObject * fPickleDumps
static void UnSerialize(TString file, PyObject **obj)
static PyObject * fGlobalNS