12 #ifndef MLPACK_BINDINGS_PYTHON_PRINT_CLASS_DEFN_HPP 13 #define MLPACK_BINDINGS_PYTHON_PRINT_CLASS_DEFN_HPP 28 const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
40 const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
51 const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
56 std::string strippedType, printedType, defaultsType;
99 std::cout <<
"cdef class " << strippedType <<
"Type:" << std::endl;
100 std::cout <<
" cdef " << printedType <<
"* modelptr" << std::endl;
101 std::cout <<
" cdef public dict scrubbed_params" << std::endl;
102 std::cout << std::endl;
103 std::cout <<
" def __cinit__(self):" << std::endl;
104 std::cout <<
" self.modelptr = new " << printedType <<
"()" << std::endl;
105 std::cout <<
" self.scrubbed_params = dict()" << std::endl;
106 std::cout << std::endl;
107 std::cout <<
" def __dealloc__(self):" << std::endl;
108 std::cout <<
" del self.modelptr" << std::endl;
109 std::cout << std::endl;
110 std::cout <<
" def __getstate__(self):" << std::endl;
111 std::cout <<
" return SerializeOut(self.modelptr, \"" << printedType
112 <<
"\")" << std::endl;
113 std::cout << std::endl;
114 std::cout <<
" def __setstate__(self, state):" << std::endl;
115 std::cout <<
" SerializeIn(self.modelptr, state, \"" << printedType
116 <<
"\")" << std::endl;
117 std::cout << std::endl;
118 std::cout <<
" def __reduce_ex__(self, version):" << std::endl;
119 std::cout <<
" return (self.__class__, (), self.__getstate__())" 121 std::cout << std::endl;
122 std::cout <<
" def _get_cpp_params(self):" << std::endl;
123 std::cout <<
" return SerializeOutJSON(self.modelptr, \"" << printedType
124 <<
"\")" << std::endl;
125 std::cout << std::endl;
126 std::cout <<
" def _set_cpp_params(self, state):" << std::endl;
127 std::cout <<
" SerializeInJSON(self.modelptr, state, \"" << printedType
128 <<
"\")" << std::endl;
129 std::cout << std::endl;
130 std::cout <<
" def get_cpp_params(self, return_str=False):" << std::endl;
131 std::cout <<
" params = self._get_cpp_params()" << std::endl;
132 std::cout <<
" return process_params_out(self, params, " 133 <<
"return_str=return_str)" << std::endl;
134 std::cout << std::endl;
135 std::cout <<
" def set_cpp_params(self, params_dic):" << std::endl;
136 std::cout <<
" params_str = process_params_in(self, params_dic)" 138 std::cout <<
" self._set_cpp_params(params_str.encode(\"utf-8\"))" 140 std::cout << std::endl;
156 PrintClassDefn<typename std::remove_pointer<T>::type>(d);
Linear algebra utility functions, generally performed on matrices or vectors.
This structure holds all of the information about a single parameter, including its value (which is s...
void PrintClassDefn(util::ParamData &, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0, const typename std::enable_if<!data::HasSerialize< T >::value >::type *=0)
Non-serializable models don't require any special definitions, so this prints nothing.
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++.