12 #ifndef MLPACK_BINDINGS_PYTHON_PRINT_CLASS_DEFN_HPP 13 #define MLPACK_BINDINGS_PYTHON_PRINT_CLASS_DEFN_HPP 28 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
40 const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
51 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
56 std::string strippedType, printedType, defaultsType;
80 std::cout <<
"cdef class " << strippedType <<
"Type:" << std::endl;
81 std::cout <<
" cdef " << printedType <<
"* modelptr" << std::endl;
82 std::cout << std::endl;
83 std::cout <<
" def __cinit__(self):" << std::endl;
84 std::cout <<
" self.modelptr = new " << printedType <<
"()" << std::endl;
85 std::cout << std::endl;
86 std::cout <<
" def __dealloc__(self):" << std::endl;
87 std::cout <<
" del self.modelptr" << std::endl;
88 std::cout << std::endl;
89 std::cout <<
" def __getstate__(self):" << std::endl;
90 std::cout <<
" return SerializeOut(self.modelptr, \"" << printedType
91 <<
"\")" << std::endl;
92 std::cout << std::endl;
93 std::cout <<
" def __setstate__(self, state):" << std::endl;
94 std::cout <<
" SerializeIn(self.modelptr, state, \"" << printedType
95 <<
"\")" << std::endl;
96 std::cout << std::endl;
97 std::cout <<
" def __reduce_ex__(self, version):" << std::endl;
98 std::cout <<
" return (self.__class__, (), self.__getstate__())" 100 std::cout << std::endl;
116 PrintClassDefn<typename std::remove_pointer<T>::type>(d);
void PrintClassDefn(const util::ParamData &, const typename boost::disable_if< arma::is_arma_type< T >>::type *=0, const typename boost::disable_if< data::HasSerialize< T >>::type *=0)
Non-serializable models don't require any special definitions, so this prints nothing.
This structure holds all of the information about a single parameter, including its value (which is s...
void StripType(const std::string &inputType, std::string &strippedType, std::string &printedType, std::string &defaultsType)
Given an input type like, e.g., "LogisticRegression<>", return three types that can be used in Python...
std::string cppType
The true name of the type, as it would be written in C++.