12 #ifndef MLPACK_BINDINGS_PYTHON_DEFAULT_PARAM_IMPL_HPP 13 #define MLPACK_BINDINGS_PYTHON_DEFAULT_PARAM_IMPL_HPP 25 std::string DefaultParamImpl(
27 const typename std::enable_if<!arma::is_arma_type<T>::value>::type* ,
30 const typename std::enable_if<!std::is_same<T,
31 std::string>::value>::type*,
32 const typename std::enable_if<!std::is_same<T,
33 std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* )
35 std::ostringstream oss;
36 if (std::is_same<T, bool>::value)
39 oss << boost::any_cast<T>(data.
value);
48 std::string DefaultParamImpl(
53 std::ostringstream oss;
54 const T& vector = boost::any_cast<T>(data.
value);
56 if (std::is_same<T, std::vector<std::string>>::value)
58 if (vector.size() > 0)
60 for (
size_t i = 0; i < vector.size() - 1; ++i)
62 oss <<
"'" << vector[i] <<
"', ";
65 oss <<
"'" << vector[vector.size() - 1] <<
"'";
72 if (vector.size() > 0)
74 for (
size_t i = 0; i < vector.size() - 1; ++i)
76 oss << vector[i] <<
", ";
79 oss << vector[vector.size() - 1];
91 std::string DefaultParamImpl(
93 const typename std::enable_if<std::is_same<T, std::string>::value>::type*)
95 const std::string& s = *boost::any_cast<std::string>(&data.
value);
104 std::string DefaultParamImpl(
106 const typename std::enable_if<
107 arma::is_arma_type<T>::value ||
109 arma::mat>>::value>::type* )
112 if (std::is_same<T, arma::rowvec>::value ||
113 std::is_same<T, arma::vec>::value)
115 return "np.empty([0])";
117 else if (std::is_same<T, arma::Col<size_t>>::value ||
118 std::is_same<T, arma::Row<size_t>>::value)
120 return "np.empty([0], dtype=np.uint64)";
122 else if (std::is_same<T, arma::Mat<size_t>>::value)
124 return "np.empty([0, 0], dtype=np.uint64)";
128 return "np.empty([0, 0])";
136 std::string DefaultParamImpl(
138 const typename std::enable_if<!arma::is_arma_type<T>::value>::type* ,
Auxiliary information for a dataset, including mappings to/from strings (or other types) and the data...
Definition: dataset_mapper.hpp:41
Definition: has_serialize.hpp:47
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:52
Metaprogramming structure for vector detection.
Definition: is_std_vector.hpp:23
boost::any value
The actual value that is held.
Definition: param_data.hpp:82