mlpack 3.4.2
import_decl.hpp
Go to the documentation of this file.
1
12#ifndef MLPACK_BINDINGS_PYTHON_IMPORT_DECL_HPP
13#define MLPACK_BINDINGS_PYTHON_IMPORT_DECL_HPP
14
15#include <mlpack/prereqs.hpp>
16#include "strip_type.hpp"
17
18namespace mlpack {
19namespace bindings {
20namespace python {
21
25template<typename T>
28 const size_t indent,
29 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
30 const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
31{
32 // First, we have to parse the type. If we have something like, e.g.,
33 // 'LogisticRegression<>', we must convert this to 'LogisticRegression[T=*].'
34 std::string strippedType, printedType, defaultsType;
35 StripType(d.cppType, strippedType, printedType, defaultsType);
36
43 const std::string prefix = std::string(indent, ' ');
44 std::cout << prefix << "cdef cppclass " << defaultsType << ":" << std::endl;
45 std::cout << prefix << " " << strippedType << "() nogil" << std::endl;
46 std::cout << prefix << std::endl;
47}
48
52template<typename T>
54 util::ParamData& /* d */,
55 const size_t /* indent */,
56 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
57 const typename boost::disable_if<data::HasSerialize<T>>::type* = 0)
58{
59 // Print nothing.
60}
61
65template<typename T>
67 util::ParamData& /* d */,
68 const size_t /* indent */,
69 const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
70{
71 // Print nothing.
72}
73
82template<typename T>
84 const void* indent,
85 void* /* output */)
86{
87 ImportDecl<typename std::remove_pointer<T>::type>(d, *((size_t*) indent));
88}
89
90} // namespace python
91} // namespace bindings
92} // namespace mlpack
93
94#endif
python
Definition: CMakeLists.txt:6
void ImportDecl(util::ParamData &d, const size_t indent, const typename boost::disable_if< arma::is_arma_type< T > >::type *=0, const typename boost::enable_if< data::HasSerialize< T > >::type *=0)
For a serializable type, print a cppclass definition.
Definition: import_decl.hpp:26
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...
Definition: strip_type.hpp:28
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:53
std::string cppType
The true name of the type, as it would be written in C++.
Definition: param_data.hpp:84