Merge remote-tracking branch 'origin/master' into julia-fix-categories

This commit is contained in:
Ryan Curtin
2021-07-06 09:32:54 -04:00
112 changed files with 1773 additions and 1096 deletions
+6 -2
View File
@@ -35,8 +35,12 @@ steps:
fi
# Install armadillo.
curl https://data.kurg.org/armadillo-8.400.0.tar.xz | tar -xvJ && cd armadillo*
cmake . && make && sudo make install && cd ..
curl https://data.kurg.org/armadillo-8.400.0.tar.xz | tar -xvJ && \
cd armadillo* && \
cmake . && \
make && \
sudo make install && \
cd ..
# Install cereal.
wget https://github.com/USCiLab/cereal/archive/v1.3.0.tar.gz
+3 -2
View File
@@ -41,7 +41,7 @@ jobs:
Rscript -e "install.packages('remotes')" -e "saveRDS(remotes::dev_package_deps(dependencies = TRUE), 'depends.Rds')"
- name: Cache R packages
if: runner.os != 'Windows'
if: runner.os != 'Windows' && runner.os != 'macOS'
uses: actions/cache@v1
with:
path: ${{ env.R_LIBS_USER }}
@@ -120,7 +120,7 @@ jobs:
run: Rscript -e "install.packages('remotes')" -e "saveRDS(remotes::dev_package_deps('${{ needs.jobR.outputs.r_bindings }}', dependencies = TRUE), 'depends.Rds')"
- name: Cache R packages
if: runner.os != 'Windows'
if: runner.os != 'Windows' && runner.os != 'macOS'
uses: actions/cache@v1
with:
path: ${{ env.R_LIBS_USER }}
@@ -129,6 +129,7 @@ jobs:
- name: Install dependencies
run: |
install.packages('remotes')
remotes::install_deps('${{ needs.jobR.outputs.r_bindings }}', dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}
+5 -2
View File
@@ -44,10 +44,13 @@ macro(get_deps LINK DEPS_NAME PACKAGE)
list(LENGTH DIRECTORIES DIRECTORIES_LEN)
if (DIRECTORIES_LEN GREATER 0)
list(GET DIRECTORIES 0 DEPENDENCY_DIR)
set(GENERIC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/deps/${DEPENDENCY_DIR}/include")
# Clean this line when boost is removed.
# Clean these lines when boost is removed.
if (${DEPS_NAME} MATCHES "boost")
set(Boost_INCLUDE_DIR "${CMAKE_BINARY_DIR}/deps/${DEPENDENCY_DIR}/")
install(DIRECTORY "${Boost_INCLUDE_DIR}/boost" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
else()
set(GENERIC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/deps/${DEPENDENCY_DIR}/include")
install(DIRECTORY "${GENERIC_INCLUDE_DIR}/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
endif()
else ()
message(FATAL_ERROR
+1 -1
View File
@@ -33,7 +33,7 @@ macro(search_openblas version)
endif()
file(GLOB OPENBLAS_LIBRARIES "${CMAKE_BINARY_DIR}/deps/OpenBLAS-${version}/libopenblas.a")
set(BLAS_openblas_LIBRARY ${OPENBLAS_LIBRARIES})
set(LAPACK_openblas_LIBRARY ${OPENBLAS_LIBRARIES})
set(LAPACK_openblas_LIBRARY ${OPENBLAS_LIBRARIES})
set(BLA_VENDOR OpenBLAS)
set(BLAS_FOUND ON)
endif()
+8 -1
View File
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.3.2)
cmake_minimum_required(VERSION 3.6)
project(mlpack C CXX)
include(CMake/cotire.cmake)
@@ -283,6 +283,13 @@ if (DISABLE_DOWNLOADS)
else()
find_package(Armadillo "${ARMADILLO_VERSION}")
if (NOT ARMADILLO_FOUND)
if (NOT CMAKE_CROSSCOMPILING)
find_package(BLAS QUIET)
find_package(LAPACK QUIET)
if (NOT BLAS_FOUND AND NOT LAPACK_FOUND)
message(FATAL_ERROR "Can not find BLAS or LAPACK! These are required for Armadillo. Please install one of them---or install Armadillo---before installing mlpack.")
endif()
endif()
get_deps(http://files.mlpack.org/armadillo-10.3.0.tar.gz armadillo armadillo-10.3.0.tar.gz)
set(ARMADILLO_INCLUDE_DIR ${GENERIC_INCLUDE_DIR})
find_package(Armadillo REQUIRED)
+4
View File
@@ -59,6 +59,10 @@
* Fixes to `HoeffdingTree`: ensure that training still works when empty
constructor is used (#2964).
* Fix Julia model serialization bug (#2970).
* Fix `LoadCSV()` to use pre-populated `DatasetInfo` objects (#2980).
* Fix Julia, Python, R, and Go handling of categorical data for
`decision_tree()` and `hoeffding_tree()` (#2971).
+1 -1
View File
@@ -101,7 +101,7 @@ mlpack has the following dependencies:
Armadillo >= 8.400.0
Boost (math_c99, spirit) >= 1.58.0
CMake >= 3.2.2
CMake >= 3.6
ensmallen >= 2.10.0
cereal >= 1.1.2
+12 -11
View File
@@ -26,12 +26,13 @@ namespace r {
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T, std::string>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::string>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Return the default value of a vector option.
@@ -39,7 +40,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0);
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
/**
* Return the default value of a string option.
@@ -47,7 +48,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T, std::string>>::type* = 0);
const typename std::enable_if<std::is_same<T, std::string>::value>::type* = 0);
/**
* Return the default value of a matrix option, a tuple option, a
@@ -57,7 +58,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if_c<
const typename std::enable_if<
arma::is_arma_type<T>::value ||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
arma::mat>>::value>::type* /* junk */ = 0);
@@ -69,8 +70,8 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Return the default value of an option. This is the function that will be
+12 -11
View File
@@ -24,12 +24,13 @@ namespace r {
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::disable_if<util::IsStdVector<T>>::type* /* junk */,
const typename boost::disable_if<data::HasSerialize<T>>::type* /* junk */,
const typename boost::disable_if<std::is_same<T, std::string>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* /* junk */,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* /* junk */,
const typename std::enable_if<!std::is_same<T,
std::string>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* /* junk */)
{
std::ostringstream oss;
if (std::is_same<T, bool>::value)
@@ -46,7 +47,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* /* junk */)
const typename std::enable_if<util::IsStdVector<T>::value>::type* /* junk */)
{
// Print each element in an array delimited by square brackets.
std::ostringstream oss;
@@ -89,7 +90,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T, std::string>>::type*)
const typename std::enable_if<std::is_same<T, std::string>::value>::type*)
{
const std::string& s = *boost::any_cast<std::string>(&data.value);
return "\"" + s + "\"";
@@ -102,7 +103,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& /* data */,
const typename boost::enable_if_c<
const typename std::enable_if<
arma::is_arma_type<T>::value ||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
arma::mat>>::value>::type* /* junk */)
@@ -132,8 +133,8 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& /* data */,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::enable_if<data::HasSerialize<T>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<data::HasSerialize<T>::value>::type* /* junk */)
{
return "NA";
}
+11 -11
View File
@@ -25,11 +25,11 @@ namespace r {
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
std::ostringstream oss;
oss << boost::any_cast<T>(data.value);
@@ -42,7 +42,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
{
const T& t = boost::any_cast<T>(data.value);
@@ -58,7 +58,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
// Get the matrix.
const T& matrix = boost::any_cast<T>(data.value);
@@ -74,8 +74,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
std::ostringstream oss;
oss << data.cppType << " model at " << boost::any_cast<T*>(data.value);
@@ -88,8 +88,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
// Get the matrix.
const T& tuple = boost::any_cast<T>(data.value);
+46 -42
View File
@@ -23,84 +23,88 @@ namespace r {
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<>
inline std::string GetPrintableType<int>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<int>>::type*,
const typename boost::disable_if<data::HasSerialize<int>>::type*,
const typename boost::disable_if<arma::is_arma_type<int>>::type*,
const typename boost::disable_if<std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
const typename std::enable_if<!std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<>
inline std::string GetPrintableType<double>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<double>>::type*,
const typename boost::disable_if<data::HasSerialize<double>>::type*,
const typename boost::disable_if<arma::is_arma_type<double>>::type*,
const typename boost::disable_if<std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
const typename std::enable_if<!std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<>
inline std::string GetPrintableType<std::string>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
const typename boost::disable_if<arma::is_arma_type<std::string>>::type*,
const typename boost::disable_if<std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<
!util::IsStdVector<std::string>::value>::type*,
const typename std::enable_if<
!data::HasSerialize<std::string>::value>::type*,
const typename std::enable_if<
!arma::is_arma_type<std::string>::value>::type*,
const typename std::enable_if<
!std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<>
inline std::string GetPrintableType<size_t>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<size_t>>::type*,
const typename boost::disable_if<data::HasSerialize<size_t>>::type*,
const typename boost::disable_if<arma::is_arma_type<size_t>>::type*,
const typename boost::disable_if<std::is_same<size_t,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<!util::IsStdVector<size_t>::value>::type*,
const typename std::enable_if<!data::HasSerialize<size_t>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<size_t>::value>::type*,
const typename std::enable_if<!std::is_same<size_t,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<>
inline std::string GetPrintableType<bool>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<bool>>::type*,
const typename boost::disable_if<data::HasSerialize<bool>>::type*,
const typename boost::disable_if<arma::is_arma_type<bool>>::type*,
const typename boost::disable_if<std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
const typename std::enable_if<!std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<typename T>
inline std::string GetPrintableType(
util::ParamData& d,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<typename T>
inline std::string GetPrintableType(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<typename T>
void GetPrintableType(util::ParamData& d,
@@ -22,11 +22,11 @@ namespace r {
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "unknown";
}
@@ -34,11 +34,11 @@ inline std::string GetPrintableType(
template<>
inline std::string GetPrintableType<int>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<int>>::type*,
const typename boost::disable_if<data::HasSerialize<int>>::type*,
const typename boost::disable_if<arma::is_arma_type<int>>::type*,
const typename boost::disable_if<std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
const typename std::enable_if<!std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "integer";
}
@@ -46,11 +46,11 @@ inline std::string GetPrintableType<int>(
template<>
inline std::string GetPrintableType<double>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<double>>::type*,
const typename boost::disable_if<data::HasSerialize<double>>::type*,
const typename boost::disable_if<arma::is_arma_type<double>>::type*,
const typename boost::disable_if<std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
const typename std::enable_if<!std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "numeric";
}
@@ -58,11 +58,15 @@ inline std::string GetPrintableType<double>(
template<>
inline std::string GetPrintableType<std::string>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
const typename boost::disable_if<arma::is_arma_type<std::string>>::type*,
const typename boost::disable_if<std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<
!util::IsStdVector<std::string>::value>::type*,
const typename std::enable_if<
!data::HasSerialize<std::string>::value>::type*,
const typename std::enable_if<
!arma::is_arma_type<std::string>::value>::type*,
const typename std::enable_if<
!std::is_same<std::string,
std::tuple<data::DatasetInfo,arma::mat>>::value>::type*)
{
return "character";
}
@@ -70,11 +74,11 @@ inline std::string GetPrintableType<std::string>(
template<>
inline std::string GetPrintableType<size_t>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<size_t>>::type*,
const typename boost::disable_if<data::HasSerialize<size_t>>::type*,
const typename boost::disable_if<arma::is_arma_type<size_t>>::type*,
const typename boost::disable_if<std::is_same<size_t,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<size_t>::value>::type*,
const typename std::enable_if<!data::HasSerialize<size_t>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<size_t>::value>::type*,
const typename std::enable_if<!std::is_same<size_t,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "integer";
}
@@ -82,11 +86,11 @@ inline std::string GetPrintableType<size_t>(
template<>
inline std::string GetPrintableType<bool>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<bool>>::type*,
const typename boost::disable_if<data::HasSerialize<bool>>::type*,
const typename boost::disable_if<arma::is_arma_type<bool>>::type*,
const typename boost::disable_if<std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
const typename std::enable_if<!std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "logical";
}
@@ -94,9 +98,9 @@ inline std::string GetPrintableType<bool>(
template<typename T>
inline std::string GetPrintableType(
util::ParamData& d,
const typename boost::enable_if<util::IsStdVector<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<util::IsStdVector<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "vector of " + GetPrintableType<typename T::value_type>(d) + "s";
}
@@ -104,9 +108,9 @@ inline std::string GetPrintableType(
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::enable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
std::string type = "numeric matrix";
if (std::is_same<typename T::elem_type, double>::value)
@@ -127,8 +131,8 @@ inline std::string GetPrintableType(
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "categorical matrix/data.frame";
}
@@ -136,10 +140,10 @@ inline std::string GetPrintableType(
template<typename T>
inline std::string GetPrintableType(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
std::string type = util::StripType(d.cppType);
if (type == "mlpackModel")
+42 -38
View File
@@ -23,11 +23,11 @@ namespace r {
template<typename T>
inline std::string GetRType(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
return "unknown";
}
@@ -35,11 +35,11 @@ inline std::string GetRType(
template<>
inline std::string GetRType<bool>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<bool>>::type*,
const typename boost::disable_if<data::HasSerialize<bool>>::type*,
const typename boost::disable_if<arma::is_arma_type<bool>>::type*,
const typename boost::disable_if<std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
const typename std::enable_if<!std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "logical";
}
@@ -47,11 +47,11 @@ inline std::string GetRType<bool>(
template<>
inline std::string GetRType<int>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<int>>::type*,
const typename boost::disable_if<data::HasSerialize<int>>::type*,
const typename boost::disable_if<arma::is_arma_type<int>>::type*,
const typename boost::disable_if<std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
const typename std::enable_if<!std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "integer";
}
@@ -59,11 +59,11 @@ inline std::string GetRType<int>(
template<>
inline std::string GetRType<size_t>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<size_t>>::type*,
const typename boost::disable_if<data::HasSerialize<size_t>>::type*,
const typename boost::disable_if<arma::is_arma_type<size_t>>::type*,
const typename boost::disable_if<std::is_same<size_t,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<size_t>::value>::type*,
const typename std::enable_if<!data::HasSerialize<size_t>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<size_t>::value>::type*,
const typename std::enable_if<!std::is_same<size_t,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "integer";
}
@@ -71,11 +71,11 @@ inline std::string GetRType<size_t>(
template<>
inline std::string GetRType<double>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<double>>::type*,
const typename boost::disable_if<data::HasSerialize<double>>::type*,
const typename boost::disable_if<arma::is_arma_type<double>>::type*,
const typename boost::disable_if<std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
const typename std::enable_if<!std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "numeric";
}
@@ -83,11 +83,15 @@ inline std::string GetRType<double>(
template<>
inline std::string GetRType<std::string>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
const typename boost::disable_if<arma::is_arma_type<std::string>>::type*,
const typename boost::disable_if<std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<
!util::IsStdVector<std::string>::value>::type*,
const typename std::enable_if<
!data::HasSerialize<std::string>::value>::type*,
const typename std::enable_if<
!arma::is_arma_type<std::string>::value>::type*,
const typename std::enable_if<
!std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "character";
}
@@ -95,7 +99,7 @@ inline std::string GetRType<std::string>(
template<typename T>
inline std::string GetRType(
util::ParamData& d,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
{
return GetRType<typename T::value_type>(d) + " vector";
}
@@ -103,9 +107,9 @@ inline std::string GetRType(
template<typename T>
inline std::string GetRType(
util::ParamData& d,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0,
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
std::string elemType = GetRType<typename T::elem_type>(d);
std::string type = "matrix";
@@ -120,8 +124,8 @@ inline std::string GetRType(
template<typename T>
inline std::string GetRType(
util::ParamData& /* d */,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
return "numeric matrix/data.frame with info";
}
@@ -129,8 +133,8 @@ inline std::string GetRType(
template<typename T>
inline std::string GetRType(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
return util::StripType(d.cppType);
}
+43 -40
View File
@@ -24,11 +24,11 @@ namespace r {
template<typename T>
inline std::string GetType(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
return "unknown";
}
@@ -36,11 +36,11 @@ inline std::string GetType(
template<>
inline std::string GetType<int>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<int>>::type*,
const typename boost::disable_if<data::HasSerialize<int>>::type*,
const typename boost::disable_if<arma::is_arma_type<int>>::type*,
const typename boost::disable_if<std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
const typename std::enable_if<!std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "Int";
}
@@ -48,11 +48,11 @@ inline std::string GetType<int>(
template<>
inline std::string GetType<float>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<float>>::type*,
const typename boost::disable_if<data::HasSerialize<float>>::type*,
const typename boost::disable_if<arma::is_arma_type<float>>::type*,
const typename boost::disable_if<std::is_same<float,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<float>::value>::type*,
const typename std::enable_if<!data::HasSerialize<float>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<float>::value>::type*,
const typename std::enable_if<!std::is_same<float,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "Float";
}
@@ -60,11 +60,11 @@ inline std::string GetType<float>(
template<>
inline std::string GetType<double>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<double>>::type*,
const typename boost::disable_if<data::HasSerialize<double>>::type*,
const typename boost::disable_if<arma::is_arma_type<double>>::type*,
const typename boost::disable_if<std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
const typename std::enable_if<!std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "Double";
}
@@ -72,11 +72,14 @@ inline std::string GetType<double>(
template<>
inline std::string GetType<std::string>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
const typename boost::disable_if<arma::is_arma_type<std::string>>::type*,
const typename boost::disable_if<std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<
!util::IsStdVector<std::string>::value>::type*,
const typename std::enable_if<
!data::HasSerialize<std::string>::value>::type*,
const typename std::enable_if<
!arma::is_arma_type<std::string>::value>::type*,
const typename std::enable_if<!std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "String";
}
@@ -84,11 +87,11 @@ inline std::string GetType<std::string>(
template<>
inline std::string GetType<bool>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<bool>>::type*,
const typename boost::disable_if<data::HasSerialize<bool>>::type*,
const typename boost::disable_if<arma::is_arma_type<bool>>::type*,
const typename boost::disable_if<std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
const typename std::enable_if<!std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "Bool";
}
@@ -96,9 +99,9 @@ inline std::string GetType<bool>(
template<typename T>
inline std::string GetType(
util::ParamData& d,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
return "Vec" + GetType<typename T::value_type>(d);
}
@@ -106,9 +109,9 @@ inline std::string GetType(
template<typename T>
inline std::string GetType(
util::ParamData& /* d */,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
std::string type = "";
if (std::is_same<typename T::elem_type, double>::value)
@@ -136,8 +139,8 @@ inline std::string GetType(
template<typename T>
inline std::string GetType(
util::ParamData& /* d */,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
return "MatWithInfo";
}
@@ -145,8 +148,8 @@ inline std::string GetType(
template<typename T>
inline std::string GetType(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
return d.cppType;
}
@@ -26,10 +26,10 @@ namespace r {
template<typename T>
void PrintInputProcessing(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
if (!d.required)
{
@@ -72,7 +72,7 @@ void PrintInputProcessing(
template<typename T>
void PrintInputProcessing(
util::ParamData& d,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
if (!d.required)
{
@@ -108,8 +108,8 @@ void PrintInputProcessing(
template<typename T>
void PrintInputProcessing(
util::ParamData& d,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
if (!d.required)
{
@@ -155,8 +155,8 @@ void PrintInputProcessing(
template<typename T>
void PrintInputProcessing(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
if (!d.required)
{
@@ -26,10 +26,10 @@ namespace r {
template<typename T>
void PrintOutputProcessing(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
/**
* This gives us code like:
@@ -48,7 +48,7 @@ void PrintOutputProcessing(
template<typename T>
void PrintOutputProcessing(
util::ParamData& d,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0,
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
@@ -69,8 +69,8 @@ void PrintOutputProcessing(
template<typename T>
void PrintOutputProcessing(
util::ParamData& d,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
/**
* This gives us code like:
@@ -89,8 +89,8 @@ void PrintOutputProcessing(
template<typename T>
void PrintOutputProcessing(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
/**
* This gives us code like:
+7 -7
View File
@@ -25,11 +25,11 @@ namespace r {
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Return a string representing the command-line type of a vector.
@@ -62,8 +62,8 @@ std::string PrintTypeDoc(
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Print the command-line type of an option into a string.
@@ -24,11 +24,11 @@ namespace r {
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<util::IsStdVector<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
// A flag type.
if (std::is_same<T, bool>::value)
@@ -146,8 +146,8 @@ std::string PrintTypeDoc(
template<typename T>
std::string PrintTypeDoc(
util::ParamData& /* data */,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
{
return "An mlpack model pointer. `<Model>` refers to the type of model that "
"is being stored, so, e.g., for `cf()`, the type will be `CFModel`. "
+38 -38
View File
@@ -33,15 +33,15 @@ template<typename T>
void AddToCLI11(const std::string& cliName,
util::ParamData& param,
CLI::App& app,
const typename boost::disable_if<std::is_same<T,
bool>>::type* = 0,
const typename boost::disable_if<
arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<
data::HasSerialize<T>>::type* = 0,
const typename boost::enable_if<std::is_same<T,
const typename std::enable_if<!std::is_same<T,
bool>::value>::type* = 0,
const typename std::enable_if<!
arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!
data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo,
arma::mat>>>::type* = 0)
arma::mat>>::value>::type* = 0)
{
app.add_option_function<std::string>(cliName.c_str(),
[&param](const std::string& value)
@@ -65,15 +65,15 @@ template<typename T>
void AddToCLI11(const std::string& cliName,
util::ParamData& param,
CLI::App& app,
const typename boost::disable_if<std::is_same<T,
bool>>::type* = 0,
const typename boost::disable_if<
arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<
data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
const typename std::enable_if<!std::is_same<T,
bool>::value>::type* = 0,
const typename std::enable_if<!
arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<
data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo,
arma::mat>>>::type* = 0)
arma::mat>>::value>::type* = 0)
{
app.add_option_function<std::string>(cliName.c_str(),
[&param](const std::string& value)
@@ -97,13 +97,13 @@ template<typename T>
void AddToCLI11(const std::string& cliName,
util::ParamData& param,
CLI::App& app,
const typename boost::disable_if<
std::is_same<T, bool>>::type* = 0,
const typename boost::enable_if<
arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
const typename std::enable_if<!
std::is_same<T, bool>::value>::type* = 0,
const typename std::enable_if<
arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo,
arma::mat>>>::type* = 0)
arma::mat>>::value>::type* = 0)
{
app.add_option_function<std::string>(cliName.c_str(),
[&param](const std::string& value)
@@ -127,15 +127,15 @@ template<typename T>
void AddToCLI11(const std::string& cliName,
util::ParamData& param,
CLI::App& app,
const typename boost::disable_if<
std::is_same<T, bool>>::type* = 0,
const typename boost::disable_if<
arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<
data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
const typename std::enable_if<!
std::is_same<T, bool>::value>::type* = 0,
const typename std::enable_if<!
arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!
data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo,
arma::mat>>>::type* = 0)
arma::mat>>::value>::type* = 0)
{
app.add_option_function<T>(cliName.c_str(),
[&param](const T& value)
@@ -157,15 +157,15 @@ template<typename T>
void AddToCLI11(const std::string& cliName,
util::ParamData& param,
CLI::App& app,
const typename boost::enable_if<
std::is_same<T, bool>>::type* = 0,
const typename boost::disable_if<
arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<
data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
const typename std::enable_if<
std::is_same<T, bool>::value>::type* = 0,
const typename std::enable_if<!
arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!
data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo,
arma::mat>>>::type* = 0)
arma::mat>>::value>::type* = 0)
{
app.add_flag_function(cliName.c_str(),
[&param](const T& value)
+12 -11
View File
@@ -26,12 +26,13 @@ namespace cli {
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T, std::string>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::string>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Return the default value of a vector option.
@@ -39,7 +40,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0);
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
/**
* Return the default value of a string option.
@@ -47,7 +48,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T, std::string>>::type* = 0);
const typename std::enable_if<std::is_same<T, std::string>::value>::type* = 0);
/**
* Return the default value of a matrix option, a tuple option, a
@@ -57,7 +58,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if_c<
const typename std::enable_if<
arma::is_arma_type<T>::value ||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
arma::mat>>::value>::type* /* junk */ = 0);
@@ -69,8 +70,8 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Return the default value of an option. This is the function that will be
+12 -11
View File
@@ -24,12 +24,13 @@ namespace cli {
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::disable_if<util::IsStdVector<T>>::type* /* junk */,
const typename boost::disable_if<data::HasSerialize<T>>::type* /* junk */,
const typename boost::disable_if<std::is_same<T, std::string>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* /* junk */,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* /* junk */,
const typename std::enable_if<!std::is_same<T,
std::string>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* /* junk */)
{
std::ostringstream oss;
if (!std::is_same<T, bool>::value)
@@ -44,7 +45,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* /* junk */)
const typename std::enable_if<util::IsStdVector<T>::value>::type* /* junk */)
{
// Print each element in an array delimited by square brackets.
std::ostringstream oss;
@@ -88,7 +89,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T, std::string>>::type*)
const typename std::enable_if<std::is_same<T, std::string>::value>::type*)
{
const std::string& s = *boost::any_cast<std::string>(&data.value);
return "'" + s + "'";
@@ -100,7 +101,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& /* data */,
const typename boost::enable_if_c<
const typename std::enable_if<
arma::is_arma_type<T>::value ||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
arma::mat>>::value>::type* /* junk */)
@@ -115,8 +116,8 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& /* data */,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::enable_if<data::HasSerialize<T>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<data::HasSerialize<T>::value>::type* /* junk */)
{
return "''";
}
@@ -21,8 +21,8 @@ namespace cli {
template<typename T>
void DeleteAllocatedMemoryImpl(
util::ParamData& /* d */,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
{
// Do nothing.
}
@@ -30,7 +30,7 @@ void DeleteAllocatedMemoryImpl(
template<typename T>
void DeleteAllocatedMemoryImpl(
util::ParamData& /* d */,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
// Do nothing.
}
@@ -38,8 +38,8 @@ void DeleteAllocatedMemoryImpl(
template<typename T>
void DeleteAllocatedMemoryImpl(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// Delete the allocated memory (hopefully we actually own it).
typedef std::tuple<T*, std::string> TupleType;
@@ -22,8 +22,8 @@ namespace cli {
template<typename T>
void* GetAllocatedMemory(
util::ParamData& /* d */,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
{
return NULL;
}
@@ -31,7 +31,7 @@ void* GetAllocatedMemory(
template<typename T>
void* GetAllocatedMemory(
util::ParamData& /* d */,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
return NULL;
}
@@ -39,8 +39,8 @@ void* GetAllocatedMemory(
template<typename T>
void* GetAllocatedMemory(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// Here we have a model, which is a tuple, and we need the address of the
// memory.
+9 -9
View File
@@ -28,10 +28,10 @@ namespace cli {
template<typename T>
T& GetParam(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
// No mapping is needed, so just cast it directly.
return *boost::any_cast<T>(&d.value);
@@ -45,7 +45,7 @@ T& GetParam(
template<typename T>
T& GetParam(
util::ParamData& d,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
// If the matrix is an input matrix, we have to load the matrix. 'value'
// contains the filename. It's possible we could load empty matrices many
@@ -80,8 +80,8 @@ T& GetParam(
template<typename T>
T& GetParam(
util::ParamData& d,
const typename boost::enable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
// If this is an input parameter, we need to load both the matrix and the
// dataset info.
@@ -110,8 +110,8 @@ T& GetParam(
template<typename T>
T*& GetParam(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// If the model is an input model, we have to load it from file. 'value'
// contains the filename.
@@ -27,11 +27,11 @@ namespace cli {
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Print a vector option, with spaces between it.
@@ -57,8 +57,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Print an option into a std::string. This should print a short, one-line
@@ -23,11 +23,11 @@ namespace cli {
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::disable_if<util::IsStdVector<T>>::type* /* junk */,
const typename boost::disable_if<data::HasSerialize<T>>::type* /* junk */,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* /* junk */,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* /* junk */,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* /* junk */)
{
std::ostringstream oss;
oss << boost::any_cast<T>(data.value);
@@ -103,8 +103,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::enable_if<data::HasSerialize<T>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<data::HasSerialize<T>::value>::type* /* junk */)
{
// Extract the string from the tuple that's being held.
typedef std::tuple<T*, typename ParameterType<T>::type> TupleType;
@@ -26,10 +26,10 @@ namespace cli {
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Get the parameter name for a matrix type (where the user has to pass the file
@@ -38,7 +38,7 @@ std::string GetPrintableParamName(
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0);
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
/**
* Get the parameter name for a serializable model type (where the user has to
@@ -47,8 +47,8 @@ std::string GetPrintableParamName(
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Get the parameter name for a mapped matrix type (where the user has to pass
@@ -57,8 +57,8 @@ std::string GetPrintableParamName(
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Get the parameter's name as seen by the user.
@@ -26,10 +26,10 @@ namespace cli {
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "--" + data.name;
}
@@ -41,7 +41,7 @@ std::string GetPrintableParamName(
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::enable_if<arma::is_arma_type<T>>::type*)
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
{
return "--" + data.name + "_file";
}
@@ -53,8 +53,8 @@ std::string GetPrintableParamName(
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
{
return "--" + data.name + "_file";
}
@@ -66,8 +66,8 @@ std::string GetPrintableParamName(
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "--" + data.name + "_file";
}
@@ -27,10 +27,10 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& data,
const std::string& value,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Get the parameter name for a matrix type (where the user has to pass the file
@@ -40,7 +40,7 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& data,
const std::string& value,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0);
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
/**
* Get the parameter name for a serializable model type (where the user has to
@@ -50,8 +50,8 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& data,
const std::string& value,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Get the parameter name for a mapped matrix type (where the user has to pass
@@ -61,8 +61,8 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& data,
const std::string& value,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Get the parameter's name as seen by the user.
@@ -28,10 +28,10 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& /* data */,
const std::string& input,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return input;
}
@@ -44,7 +44,7 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& /* data */,
const std::string& input,
const typename boost::enable_if<arma::is_arma_type<T>>::type*)
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
{
return input + ".csv";
}
@@ -57,8 +57,8 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& /* data */,
const std::string& input,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
{
return input + ".bin";
}
@@ -71,8 +71,8 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& /* data */,
const std::string& input,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return input + ".arff";
}
@@ -23,11 +23,11 @@ namespace cli {
template<typename T>
std::string GetPrintableType(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Return a string representing the command-line type of a vector.
@@ -60,8 +60,8 @@ std::string GetPrintableType(
template<typename T>
std::string GetPrintableType(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Print the command-line type of an option into a string.
@@ -25,11 +25,11 @@ namespace cli {
template<typename T>
std::string GetPrintableType(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<util::IsStdVector<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
if (std::is_same<T, bool>::value)
return "flag";
@@ -101,8 +101,8 @@ std::string GetPrintableType(
template<typename T>
std::string GetPrintableType(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
{
return data.cppType + " file";
}
+7 -7
View File
@@ -27,10 +27,10 @@ namespace cli {
template<typename T>
T& GetRawParam(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
// No mapping is needed, so just cast it directly.
return *boost::any_cast<T>(&d.value);
@@ -42,7 +42,7 @@ T& GetRawParam(
template<typename T>
T& GetRawParam(
util::ParamData& d,
const typename boost::enable_if_c<
const typename std::enable_if<
arma::is_arma_type<T>::value ||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
arma::mat>>::value>::type* = 0)
@@ -59,8 +59,8 @@ T& GetRawParam(
template<typename T>
T*& GetRawParam(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// Don't load the model.
typedef std::tuple<T*, std::string> TupleType;
+4 -4
View File
@@ -31,10 +31,10 @@ template<typename T>
void InPlaceCopyInternal(
util::ParamData& /* d */,
util::ParamData& /* input */,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
// Nothing to do.
}
@@ -27,10 +27,10 @@ namespace cli {
template<typename T>
std::string MapParameterName(
const std::string& identifier,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
return identifier;
}
@@ -43,7 +43,7 @@ std::string MapParameterName(
template<typename T>
std::string MapParameterName(
const std::string& identifier,
const typename boost::enable_if_c<
const typename std::enable_if<
arma::is_arma_type<T>::value ||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
arma::mat>>::value ||
+11 -11
View File
@@ -26,11 +26,11 @@ namespace cli {
template<typename T>
void OutputParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Output a vector option (print to stdout).
@@ -38,7 +38,7 @@ void OutputParamImpl(
template<typename T>
void OutputParamImpl(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0);
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
/**
* Output a matrix option (this saves it to the given file).
@@ -46,7 +46,7 @@ void OutputParamImpl(
template<typename T>
void OutputParamImpl(
util::ParamData& data,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0);
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
/**
* Output a serializable class option (this saves it to the given file).
@@ -54,8 +54,8 @@ void OutputParamImpl(
template<typename T>
void OutputParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Output a mapped dataset.
@@ -63,8 +63,8 @@ void OutputParamImpl(
template<typename T>
void OutputParamImpl(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Output an option. This is the function that will be called by the IO
+11 -11
View File
@@ -24,11 +24,11 @@ namespace cli {
template<typename T>
void OutputParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::disable_if<util::IsStdVector<T>>::type* /* junk */,
const typename boost::disable_if<data::HasSerialize<T>>::type* /* junk */,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* /* junk */,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* /* junk */,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* /* junk */)
{
std::cout << data.name << ": " << *boost::any_cast<T>(&data.value)
<< std::endl;
@@ -38,7 +38,7 @@ void OutputParamImpl(
template<typename T>
void OutputParamImpl(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* /* junk */)
const typename std::enable_if<util::IsStdVector<T>::value>::type* /* junk */)
{
std::cout << data.name << ": ";
const T& t = *boost::any_cast<T>(&data.value);
@@ -51,7 +51,7 @@ void OutputParamImpl(
template<typename T>
void OutputParamImpl(
util::ParamData& data,
const typename boost::enable_if<arma::is_arma_type<T>>::type* /* junk */)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* /* junk */)
{
typedef std::tuple<T, std::tuple<std::string, size_t, size_t>> TupleType;
const T& output = std::get<0>(*boost::any_cast<TupleType>(&data.value));
@@ -71,8 +71,8 @@ void OutputParamImpl(
template<typename T>
void OutputParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::enable_if<data::HasSerialize<T>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<data::HasSerialize<T>::value>::type* /* junk */)
{
// The const cast is necessary here because Serialize() can't ever be marked
// const. In this case we can assume it though, since we will be saving and
@@ -91,8 +91,8 @@ void OutputParamImpl(
template<typename T>
void OutputParamImpl(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* /* junk */)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* /* junk */)
{
// Output the matrix with the mappings.
typedef std::tuple<T, std::tuple<std::string, size_t, size_t>> TupleType;
+7 -7
View File
@@ -25,11 +25,11 @@ namespace cli {
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Return a string representing the command-line type of a vector.
@@ -62,8 +62,8 @@ std::string PrintTypeDoc(
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Print the command-line type of an option into a string.
@@ -24,11 +24,11 @@ namespace cli {
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<util::IsStdVector<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
// A flag type.
if (std::is_same<T, bool>::value)
@@ -165,8 +165,8 @@ std::string PrintTypeDoc(
template<typename T>
std::string PrintTypeDoc(
util::ParamData& /* data */,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
{
return "A filename containing an mlpack model. These can have one of three "
"formats: binary (.bin), text (.txt), and XML (.xml). The XML format "
+8 -8
View File
@@ -27,11 +27,11 @@ template<typename T>
void SetParam(
util::ParamData& d,
const boost::any& value,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0,
const typename boost::disable_if<std::is_same<T, bool>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T, bool>::value>::type* = 0)
{
// No mapping is needed.
d.value = value;
@@ -44,7 +44,7 @@ template<typename T>
void SetParam(
util::ParamData& d,
const boost::any& /* value */,
const typename boost::enable_if<std::is_same<T, bool>>::type* = 0)
const typename std::enable_if<std::is_same<T, bool>::value>::type* = 0)
{
// Force set to the value of whether or not this was passed.
d.value = d.wasPassed;
@@ -76,8 +76,8 @@ template<typename T>
void SetParam(
util::ParamData& d,
const boost::any& value,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// We're setting the string filename.
typedef std::tuple<T*, typename ParameterType<T>::type> TupleType;
@@ -26,22 +26,22 @@ namespace cli {
*/
template<typename T>
std::string StringTypeParamImpl(
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0);
/**
* Return a string containing the type of the parameter, for vector options.
*/
template<typename T>
std::string StringTypeParamImpl(
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0);
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
/**
* Return a string containing the type of the parameter,
*/
template<typename T>
std::string StringTypeParamImpl(
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Return a string containing the type of a parameter. This overload is used if
@@ -23,8 +23,8 @@ namespace cli {
*/
template<typename T>
std::string StringTypeParamImpl(
const typename boost::disable_if<util::IsStdVector<T>>::type* /* junk */,
const typename boost::disable_if<data::HasSerialize<T>>::type* /* junk */)
const typename std::enable_if<!util::IsStdVector<T>::value>::type* /* junk */,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* /* junk */)
{
// Don't know what type this is.
return "unknown";
@@ -35,7 +35,7 @@ std::string StringTypeParamImpl(
*/
template<typename T>
std::string StringTypeParamImpl(
const typename boost::enable_if<util::IsStdVector<T>>::type* /* junk */)
const typename std::enable_if<util::IsStdVector<T>::value>::type* /* junk */)
{
return "vector";
}
@@ -45,7 +45,7 @@ std::string StringTypeParamImpl(
*/
template<typename T>
std::string StringTypeParamImpl(
const typename boost::enable_if<data::HasSerialize<T>>::type* /* junk */)
const typename std::enable_if<data::HasSerialize<T>::value>::type* /* junk */)
{
return "string";
}
+13 -12
View File
@@ -26,12 +26,13 @@ namespace go {
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T, std::string>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::string>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Return the default value of a vector option.
@@ -39,7 +40,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0);
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
/**
* Return the default value of a string option.
@@ -47,7 +48,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T, std::string>>::type* = 0);
const typename std::enable_if<std::is_same<T, std::string>::value>::type* = 0);
/**
* Return the default value of a matrix option, a tuple option, a
@@ -57,10 +58,10 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if_c<
const typename std::enable_if<
arma::is_arma_type<T>::value ||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
arma::mat>>::value>::type* /* junk */ = 0);
arma::mat>>::value>::type* = 0);
/**
* Return the default value of a model option (this returns the default
@@ -69,8 +70,8 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Return the default value of an option. This is the function that will be
+12 -11
View File
@@ -24,12 +24,13 @@ namespace go {
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::disable_if<util::IsStdVector<T>>::type* /* junk */,
const typename boost::disable_if<data::HasSerialize<T>>::type* /* junk */,
const typename boost::disable_if<std::is_same<T, std::string>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* /* junk */,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* /* junk */,
const typename std::enable_if<!std::is_same<T,
std::string>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* /* junk */)
{
std::ostringstream oss;
if (std::is_same<T, bool>::value)
@@ -46,7 +47,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* /* junk */)
const typename std::enable_if<util::IsStdVector<T>::value>::type* /* junk */)
{
// Print each element in an array delimited by square brackets.
std::ostringstream oss;
@@ -90,7 +91,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T, std::string>>::type*)
const typename std::enable_if<std::is_same<T, std::string>::value>::type*)
{
const std::string& s = *boost::any_cast<std::string>(&data.value);
return "\"" + s + "\"";
@@ -102,7 +103,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& /* data */,
const typename boost::enable_if_c<
const typename std::enable_if<
arma::is_arma_type<T>::value ||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
arma::mat>>::value>::type* /* junk */)
@@ -134,8 +135,8 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& /* data */,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::enable_if<data::HasSerialize<T>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<data::HasSerialize<T>::value>::type* /* junk */)
{
return "nil";
}
+41 -38
View File
@@ -25,11 +25,11 @@ namespace go {
template<typename T>
inline std::string GetGoType(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
return "unknown";
}
@@ -37,11 +37,11 @@ inline std::string GetGoType(
template<>
inline std::string GetGoType<int>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<int>>::type*,
const typename boost::disable_if<data::HasSerialize<int>>::type*,
const typename boost::disable_if<arma::is_arma_type<int>>::type*,
const typename boost::disable_if<std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
const typename std::enable_if<!std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "int";
}
@@ -49,11 +49,11 @@ inline std::string GetGoType<int>(
template<>
inline std::string GetGoType<float>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<float>>::type*,
const typename boost::disable_if<data::HasSerialize<float>>::type*,
const typename boost::disable_if<arma::is_arma_type<float>>::type*,
const typename boost::disable_if<std::is_same<float,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<float>::value>::type*,
const typename std::enable_if<!data::HasSerialize<float>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<float>::value>::type*,
const typename std::enable_if<!std::is_same<float,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "float32";
}
@@ -61,11 +61,11 @@ inline std::string GetGoType<float>(
template<>
inline std::string GetGoType<double>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<double>>::type*,
const typename boost::disable_if<data::HasSerialize<double>>::type*,
const typename boost::disable_if<arma::is_arma_type<double>>::type*,
const typename boost::disable_if<std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
const typename std::enable_if<!std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "float64";
}
@@ -73,11 +73,14 @@ inline std::string GetGoType<double>(
template<>
inline std::string GetGoType<std::string>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
const typename boost::disable_if<arma::is_arma_type<std::string>>::type*,
const typename boost::disable_if<std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<
!util::IsStdVector<std::string>::value>::type*,
const typename std::enable_if<
!data::HasSerialize<std::string>::value>::type*,
const typename std::enable_if<
!arma::is_arma_type<std::string>::value>::type*,
const typename std::enable_if<!std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "string";
}
@@ -85,11 +88,11 @@ inline std::string GetGoType<std::string>(
template<>
inline std::string GetGoType<bool>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<bool>>::type*,
const typename boost::disable_if<data::HasSerialize<bool>>::type*,
const typename boost::disable_if<arma::is_arma_type<bool>>::type*,
const typename boost::disable_if<std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
const typename std::enable_if<!std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "bool";
}
@@ -97,7 +100,7 @@ inline std::string GetGoType<bool>(
template<typename T>
inline std::string GetGoType(
util::ParamData& d,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
{
return "[]" + GetGoType<typename T::value_type>(d);
}
@@ -105,9 +108,9 @@ inline std::string GetGoType(
template<typename T>
inline std::string GetGoType(
util::ParamData& /* d */,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0,
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
return "mat.Dense";
}
@@ -115,8 +118,8 @@ inline std::string GetGoType(
template<typename T>
inline std::string GetGoType(
util::ParamData& /* d */,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
return "matrixWithInfo";
}
@@ -124,8 +127,8 @@ inline std::string GetGoType(
template<typename T>
inline std::string GetGoType(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
std::string goStrippedType, strippedType, printedType, defaultsType;
StripType(d.cppType, goStrippedType, strippedType, printedType, defaultsType);
+11 -11
View File
@@ -25,11 +25,11 @@ namespace go {
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
std::ostringstream oss;
oss << boost::any_cast<T>(data.value);
@@ -42,7 +42,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
{
const T& t = boost::any_cast<T>(data.value);
@@ -58,7 +58,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
// Get the matrix.
const T& matrix = boost::any_cast<T>(data.value);
@@ -74,8 +74,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
std::ostringstream oss;
oss << data.cppType << " model at " << boost::any_cast<T*>(data.value);
@@ -88,8 +88,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
// Get the matrix.
const T& tuple = boost::any_cast<T>(data.value);
+40 -37
View File
@@ -23,75 +23,78 @@ namespace go {
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<>
inline std::string GetPrintableType<int>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<int>>::type*,
const typename boost::disable_if<data::HasSerialize<int>>::type*,
const typename boost::disable_if<arma::is_arma_type<int>>::type*,
const typename boost::disable_if<std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
const typename std::enable_if<!std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<>
inline std::string GetPrintableType<double>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<double>>::type*,
const typename boost::disable_if<data::HasSerialize<double>>::type*,
const typename boost::disable_if<arma::is_arma_type<double>>::type*,
const typename boost::disable_if<std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
const typename std::enable_if<!std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<>
inline std::string GetPrintableType<std::string>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
const typename boost::disable_if<arma::is_arma_type<std::string>>::type*,
const typename boost::disable_if<std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<
!util::IsStdVector<std::string>::value>::type*,
const typename std::enable_if<
!data::HasSerialize<std::string>::value>::type*,
const typename std::enable_if<
!arma::is_arma_type<std::string>::value>::type*,
const typename std::enable_if<!std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<>
inline std::string GetPrintableType<bool>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<bool>>::type*,
const typename boost::disable_if<data::HasSerialize<bool>>::type*,
const typename boost::disable_if<arma::is_arma_type<bool>>::type*,
const typename boost::disable_if<std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
const typename std::enable_if<!std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<typename T>
inline std::string GetPrintableType(
util::ParamData& d,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<typename T>
inline std::string GetPrintableType(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<typename T>
void GetPrintableType(util::ParamData& d,
@@ -23,11 +23,11 @@ namespace go {
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "unknown";
}
@@ -35,11 +35,11 @@ inline std::string GetPrintableType(
template<>
inline std::string GetPrintableType<int>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<int>>::type*,
const typename boost::disable_if<data::HasSerialize<int>>::type*,
const typename boost::disable_if<arma::is_arma_type<int>>::type*,
const typename boost::disable_if<std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
const typename std::enable_if<!std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "int";
}
@@ -47,11 +47,11 @@ inline std::string GetPrintableType<int>(
template<>
inline std::string GetPrintableType<double>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<double>>::type*,
const typename boost::disable_if<data::HasSerialize<double>>::type*,
const typename boost::disable_if<arma::is_arma_type<double>>::type*,
const typename boost::disable_if<std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
const typename std::enable_if<!std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "float64";
}
@@ -59,11 +59,14 @@ inline std::string GetPrintableType<double>(
template<>
inline std::string GetPrintableType<std::string>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
const typename boost::disable_if<arma::is_arma_type<std::string>>::type*,
const typename boost::disable_if<std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<
!util::IsStdVector<std::string>::value>::type*,
const typename std::enable_if<
!data::HasSerialize<std::string>::value>::type*,
const typename std::enable_if<
!arma::is_arma_type<std::string>::value>::type*,
const typename std::enable_if<!std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "string";
}
@@ -71,11 +74,11 @@ inline std::string GetPrintableType<std::string>(
template<>
inline std::string GetPrintableType<bool>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<bool>>::type*,
const typename boost::disable_if<data::HasSerialize<bool>>::type*,
const typename boost::disable_if<arma::is_arma_type<bool>>::type*,
const typename boost::disable_if<std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
const typename std::enable_if<!std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "bool";
}
@@ -83,9 +86,9 @@ inline std::string GetPrintableType<bool>(
template<typename T>
inline std::string GetPrintableType(
util::ParamData& d,
const typename boost::enable_if<util::IsStdVector<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<util::IsStdVector<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "array of " + GetPrintableType<typename T::value_type>(d) + "s";
}
@@ -93,9 +96,9 @@ inline std::string GetPrintableType(
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::enable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
std::string type = "*mat.Dense";
if (T::is_row || T::is_col)
@@ -107,8 +110,8 @@ inline std::string GetPrintableType(
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "matrixWithInfo";
}
@@ -116,10 +119,10 @@ inline std::string GetPrintableType(
template<typename T>
inline std::string GetPrintableType(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
std::string goStrippedType, strippedType, printedType, defaultsType;
StripType(d.cppType, goStrippedType, strippedType, printedType, defaultsType);
+25 -22
View File
@@ -24,9 +24,9 @@ namespace go {
template<typename T>
inline std::string GetType(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
{
return "unknown";
}
@@ -34,9 +34,9 @@ inline std::string GetType(
template<>
inline std::string GetType<int>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<int>>::type*,
const typename boost::disable_if<data::HasSerialize<int>>::type*,
const typename boost::disable_if<arma::is_arma_type<int>>::type*)
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*)
{
return "Int";
}
@@ -44,9 +44,9 @@ inline std::string GetType<int>(
template<>
inline std::string GetType<float>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<float>>::type*,
const typename boost::disable_if<data::HasSerialize<float>>::type*,
const typename boost::disable_if<arma::is_arma_type<float>>::type*)
const typename std::enable_if<!util::IsStdVector<float>::value>::type*,
const typename std::enable_if<!data::HasSerialize<float>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<float>::value>::type*)
{
return "Float";
}
@@ -54,9 +54,9 @@ inline std::string GetType<float>(
template<>
inline std::string GetType<double>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<double>>::type*,
const typename boost::disable_if<data::HasSerialize<double>>::type*,
const typename boost::disable_if<arma::is_arma_type<double>>::type*)
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*)
{
return "Double";
}
@@ -64,9 +64,12 @@ inline std::string GetType<double>(
template<>
inline std::string GetType<std::string>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
const typename boost::disable_if<arma::is_arma_type<std::string>>::type*)
const typename std::enable_if<
!util::IsStdVector<std::string>::value>::type*,
const typename std::enable_if<
!data::HasSerialize<std::string>::value>::type*,
const typename std::enable_if<
!arma::is_arma_type<std::string>::value>::type*)
{
return "String";
}
@@ -74,9 +77,9 @@ inline std::string GetType<std::string>(
template<>
inline std::string GetType<bool>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<bool>>::type*,
const typename boost::disable_if<data::HasSerialize<bool>>::type*,
const typename boost::disable_if<arma::is_arma_type<bool>>::type*)
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*)
{
return "Bool";
}
@@ -84,7 +87,7 @@ inline std::string GetType<bool>(
template<typename T>
inline std::string GetType(
util::ParamData& d,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
{
return "Vec" + GetType<typename T::value_type>(d);
}
@@ -92,7 +95,7 @@ inline std::string GetType(
template<typename T>
inline std::string GetType(
util::ParamData& /* d */,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
std::string type = "";
if (std::is_same<typename T::elem_type, double>::value)
@@ -120,8 +123,8 @@ inline std::string GetType(
template<typename T>
inline std::string GetType(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
return d.cppType + "*";
}
+9 -9
View File
@@ -28,10 +28,10 @@ namespace go {
template<typename T>
void PrintDefnInput(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
if (d.required)
{
@@ -46,7 +46,7 @@ void PrintDefnInput(
template<typename T>
void PrintDefnInput(
util::ParamData& d,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
// param_name *mat.Dense
if (d.required)
@@ -62,8 +62,8 @@ void PrintDefnInput(
template<typename T>
void PrintDefnInput(
util::ParamData& d,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
// param_name *DataWithInfo
if (d.required)
@@ -79,8 +79,8 @@ void PrintDefnInput(
template<typename T>
void PrintDefnInput(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// Get the type names we need to use.
std::string goStrippedType, strippedType, printedType, defaultsType;
+9 -9
View File
@@ -27,10 +27,10 @@ namespace go {
template<typename T>
void PrintDefnOutput(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
std::cout << GetGoType<T>(d);
}
@@ -41,7 +41,7 @@ void PrintDefnOutput(
template<typename T>
void PrintDefnOutput(
util::ParamData& d,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
// *mat.Dense
std::cout << "*" << GetGoType<T>(d);
@@ -53,8 +53,8 @@ void PrintDefnOutput(
template<typename T>
void PrintDefnOutput(
util::ParamData& d,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
// *mat.Dense
std::cout << "*" << GetGoType<T>(d);
@@ -66,8 +66,8 @@ void PrintDefnOutput(
template<typename T>
void PrintDefnOutput(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// Get the type names we need to use.
std::string goStrippedType, strippedType, printedType, defaultsType;
@@ -29,10 +29,10 @@ template<typename T>
void PrintInputProcessing(
util::ParamData& d,
const size_t indent,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -129,7 +129,7 @@ template<typename T>
void PrintInputProcessing(
util::ParamData& d,
const size_t indent,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -189,8 +189,8 @@ template<typename T>
void PrintInputProcessing(
util::ParamData& d,
const size_t indent,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -250,8 +250,8 @@ template<typename T>
void PrintInputProcessing(
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)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// First, get the correct classparamName if needed.
std::string goStrippedType, strippedType, printedType, defaultsType;
@@ -29,10 +29,10 @@ template<typename T>
void PrintMethodConfig(
util::ParamData& d,
const size_t indent,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -64,7 +64,7 @@ template<typename T>
void PrintMethodConfig(
util::ParamData& d,
const size_t indent,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -96,8 +96,8 @@ template<typename T>
void PrintMethodConfig(
util::ParamData& d,
const size_t indent,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -129,8 +129,8 @@ template<typename T>
void PrintMethodConfig(
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)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
+9 -9
View File
@@ -29,10 +29,10 @@ template<typename T>
void PrintMethodInit(
util::ParamData& d,
const size_t indent,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -86,7 +86,7 @@ template<typename T>
void PrintMethodInit(
util::ParamData& d,
const size_t indent,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -118,8 +118,8 @@ template<typename T>
void PrintMethodInit(
util::ParamData& d,
const size_t indent,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -151,8 +151,8 @@ template<typename T>
void PrintMethodInit(
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)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -29,10 +29,10 @@ template<typename T>
void PrintOutputProcessing(
util::ParamData& d,
const size_t indent,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -56,7 +56,7 @@ template<typename T>
void PrintOutputProcessing(
util::ParamData& d,
const size_t indent,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0,
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
@@ -83,8 +83,8 @@ template<typename T>
void PrintOutputProcessing(
util::ParamData& d,
const size_t indent,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -109,8 +109,8 @@ template<typename T>
void PrintOutputProcessing(
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)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// Get the type names we need to use.
std::string goStrippedType, strippedType, printedType, defaultsType;
+7 -7
View File
@@ -25,11 +25,11 @@ namespace go {
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Return a string representing the command-line type of a vector.
@@ -62,8 +62,8 @@ std::string PrintTypeDoc(
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Print the command-line type of an option into a string.
@@ -24,11 +24,11 @@ namespace go {
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<util::IsStdVector<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
// A flag type.
if (std::is_same<T, bool>::value)
@@ -122,8 +122,8 @@ std::string PrintTypeDoc(
template<typename T>
std::string PrintTypeDoc(
util::ParamData& /* data */,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
{
return "An mlpack model pointer. This type holds a pointer to C++ memory "
"containing the mlpack model. Note that this means the mlpack model "
+13 -12
View File
@@ -26,12 +26,13 @@ namespace julia {
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T, std::string>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::string>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Return the default value of a vector option.
@@ -39,7 +40,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0);
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
/**
* Return the default value of a string option.
@@ -47,7 +48,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T, std::string>>::type* = 0);
const typename std::enable_if<std::is_same<T, std::string>::value>::type* = 0);
/**
* Return the default value of a matrix option, a tuple option, a
@@ -57,10 +58,10 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if_c<
const typename std::enable_if<
arma::is_arma_type<T>::value ||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
arma::mat>>::value>::type* /* junk */ = 0);
arma::mat>>::value>::type* = 0);
/**
* Return the default value of a model option (this returns the default
@@ -69,8 +70,8 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Return the default value of an option. This is the function that will be
@@ -24,12 +24,13 @@ namespace julia {
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::disable_if<util::IsStdVector<T>>::type* /* junk */,
const typename boost::disable_if<data::HasSerialize<T>>::type* /* junk */,
const typename boost::disable_if<std::is_same<T, std::string>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* /* junk */,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* /* junk */,
const typename std::enable_if<!std::is_same<T,
std::string>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* /* junk */)
{
std::ostringstream oss;
if (std::is_same<T, bool>::value)
@@ -46,7 +47,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* /* junk */)
const typename std::enable_if<util::IsStdVector<T>::value>::type* /* junk */)
{
// Print each element in an array delimited by square brackets.
std::ostringstream oss;
@@ -89,7 +90,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T, std::string>>::type*)
const typename std::enable_if<std::is_same<T, std::string>::value>::type*)
{
const std::string& s = *boost::any_cast<std::string>(&data.value);
return "\"" + s + "\"";
@@ -102,7 +103,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& /* data */,
const typename boost::enable_if_c<
const typename std::enable_if<
arma::is_arma_type<T>::value ||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
arma::mat>>::value>::type* /* junk */)
@@ -134,8 +135,8 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& /* data */,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::enable_if<data::HasSerialize<T>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<data::HasSerialize<T>::value>::type* /* junk */)
{
return "nothing";
}
@@ -25,11 +25,11 @@ namespace julia {
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
std::ostringstream oss;
oss << boost::any_cast<T>(data.value);
@@ -42,7 +42,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
{
const T& t = boost::any_cast<T>(data.value);
@@ -58,7 +58,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
// Get the matrix.
const T& matrix = boost::any_cast<T>(data.value);
@@ -74,8 +74,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
std::ostringstream oss;
oss << data.cppType << " model at " << boost::any_cast<T*>(data.value);
@@ -88,8 +88,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
// Get the matrix.
const T& tuple = boost::any_cast<T>(data.value);
@@ -23,11 +23,11 @@ namespace julia {
template<typename T>
std::string GetPrintableType(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Return a string representing the command-line type of a vector.
@@ -60,8 +60,8 @@ std::string GetPrintableType(
template<typename T>
std::string GetPrintableType(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Print the command-line type of an option into a string.
@@ -26,11 +26,11 @@ namespace julia {
template<typename T>
std::string GetPrintableType(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<util::IsStdVector<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
if (std::is_same<T, bool>::value)
return "Bool";
@@ -102,8 +102,8 @@ std::string GetPrintableType(
template<typename T>
std::string GetPrintableType(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
{
std::string type = util::StripType(data.cppType);
if (type == "mlpackModel")
@@ -79,12 +79,14 @@ void PrintParamDefn(
// buffer = ccall((:Serialize<Type>Ptr, <programName>Library),
// Vector{UInt8}, (Ptr{Nothing}, Ptr{UInt8}), model.ptr,
// Base.pointer(buf_len))
// buf = Base.unsafe_wrap(buf_ptr, buf_len[0]; own=true)
// buf = Base.unsafe_wrap(buf_ptr, buf_len[1]; own=true)
// write(stream, buf_len[1])
// write(stream, buf)
// end
//
// function deserialize<Type>(stream::IO)::<Type>
// buffer = read(stream)
// buf_len = read(stream, UInt)
// buffer = read(stream, buf_len)
// <Type>(ccall((:Deserialize<Type>Ptr, <programName>Library),
// Ptr{Nothing}, (Vector{UInt8}, UInt), buffer, length(buffer)))
// end
@@ -138,6 +140,7 @@ void PrintParamDefn(
<< "Base.pointer(buf_len))" << std::endl;
std::cout << " buf = Base.unsafe_wrap(Vector{UInt8}, buf_ptr, buf_len[1]; "
<< "own=true)" << std::endl;
std::cout << " write(stream, buf_len[1])" << std::endl;
std::cout << " write(stream, buf)" << std::endl;
std::cout << "end" << std::endl;
@@ -145,7 +148,8 @@ void PrintParamDefn(
std::cout << "# Deserialize a model from the given stream." << std::endl;
std::cout << "function deserialize" << type << "(stream::IO)::" << type
<< std::endl;
std::cout << " buffer = read(stream)" << std::endl;
std::cout << " buf_len = read(stream, UInt)" << std::endl;
std::cout << " buffer = read(stream, buf_len)" << std::endl;
std::cout << " " << type << "(ccall((:Deserialize" << type << "Ptr, "
<< programName << "Library), Ptr{Nothing}, (Ptr{UInt8}, UInt), "
<< "Base.pointer(buffer), length(buffer)))" << std::endl;
+7 -7
View File
@@ -25,11 +25,11 @@ namespace julia {
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Return a string representing the command-line type of a vector.
@@ -62,8 +62,8 @@ std::string PrintTypeDoc(
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Print the command-line type of an option into a string.
@@ -24,11 +24,11 @@ namespace julia {
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<util::IsStdVector<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
// A flag type.
if (std::is_same<T, bool>::value)
@@ -154,8 +154,8 @@ std::string PrintTypeDoc(
template<typename T>
std::string PrintTypeDoc(
util::ParamData& /* data */,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
{
return "An mlpack model pointer. `<Model>` refers to the type of model that "
"is being stored, so, e.g., for `CF()`, the type will be `CFModel`. "
@@ -400,6 +400,27 @@ end
model_in=newModel)
end
# Test that we can serialize a model as part of a larger tuple.
@testset "TestStreamTupleSerialization" begin
_, _, _, _, _, _, modelOut, _, _, _, _, _, _, _ =
test_julia_binding(4.0, 12, "hello",
build_model=true)
stream = IOBuffer()
serialize(stream, (modelOut, 3, 4, 5))
newStream = IOBuffer(copy(stream.data))
(newModel, a, b, c) = deserialize(newStream)
_, _, _, _, _, bwOut, _, _, _, _, _, _, _, _ =
test_julia_binding(4.0, 12, "hello",
model_in=newModel)
@test a == 3
@test b == 4
@test c == 5
end
@testset "TestFileSerialization" begin
_, _, _, _, _, _, modelOut, _, _, _, _, _, _, _ =
test_julia_binding(4.0, 12, "hello",
@@ -25,11 +25,11 @@ namespace markdown {
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
std::ostringstream oss;
oss << boost::any_cast<T>(data.value);
@@ -42,7 +42,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
{
const T& t = boost::any_cast<T>(data.value);
@@ -58,7 +58,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
// Get the matrix.
const T& matrix = boost::any_cast<T>(data.value);
@@ -74,8 +74,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
std::ostringstream oss;
oss << data.cppType << " model at " << boost::any_cast<T*>(data.value);
@@ -88,8 +88,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
// Get the matrix.
const T& tuple = boost::any_cast<T>(data.value);
@@ -26,10 +26,10 @@ namespace markdown {
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Get the parameter name for a matrix type (where the user has to pass the file
@@ -38,7 +38,7 @@ std::string GetPrintableParamName(
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0);
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
/**
* Get the parameter name for a serializable model type (where the user has to
@@ -47,8 +47,8 @@ std::string GetPrintableParamName(
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Get the parameter name for a mapped matrix type (where the user has to pass
@@ -57,8 +57,8 @@ std::string GetPrintableParamName(
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Get the parameter's name as seen by the user.
@@ -26,10 +26,10 @@ namespace markdown {
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "--" + data.name;
}
@@ -41,7 +41,7 @@ std::string GetPrintableParamName(
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::enable_if<arma::is_arma_type<T>>::type*)
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
{
return "--" + data.name + "_file";
}
@@ -53,8 +53,8 @@ std::string GetPrintableParamName(
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
{
return "--" + data.name + "_file";
}
@@ -66,8 +66,8 @@ std::string GetPrintableParamName(
template<typename T>
std::string GetPrintableParamName(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "--" + data.name + "_file";
}
@@ -27,10 +27,10 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& data,
const std::string& value,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Get the parameter name for a matrix type (where the user has to pass the file
@@ -40,7 +40,7 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& data,
const std::string& value,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0);
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
/**
* Get the parameter name for a serializable model type (where the user has to
@@ -50,8 +50,8 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& data,
const std::string& value,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Get the parameter name for a mapped matrix type (where the user has to pass
@@ -61,8 +61,8 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& data,
const std::string& value,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Get the parameter's name as seen by the user.
@@ -28,10 +28,10 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& /* data */,
const std::string& input,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return input;
}
@@ -44,7 +44,7 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& /* data */,
const std::string& input,
const typename boost::enable_if<arma::is_arma_type<T>>::type*)
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
{
return input + ".csv";
}
@@ -57,8 +57,8 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& /* data */,
const std::string& input,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
{
return input + ".bin";
}
@@ -71,8 +71,8 @@ template<typename T>
std::string GetPrintableParamValue(
util::ParamData& /* data */,
const std::string& input,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return input + ".arff";
}
@@ -25,7 +25,7 @@ namespace markdown {
*/
template<typename T>
bool IsSerializable(
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0)
{
return false;
}
@@ -35,8 +35,8 @@ bool IsSerializable(
*/
template<typename T>
bool IsSerializable(
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
{
return true;
}
+4 -2
View File
@@ -9,11 +9,13 @@
* 3-clause BSD license along with mlpack. If not, see
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
*/
#include "print_docs.hpp"
#include <mlpack/core/util/io.hpp>
#include <mlpack/core/util/binding_details.hpp>
#include <boost/algorithm/string/replace.hpp>
#include "binding_info.hpp"
#include "print_docs.hpp"
#include "print_doc_functions.hpp"
// Make sure that this is defined.
+13 -12
View File
@@ -26,12 +26,13 @@ namespace python {
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T, std::string>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::string>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Return the default value of a vector option.
@@ -39,7 +40,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0);
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
/**
* Return the default value of a string option.
@@ -47,7 +48,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T, std::string>>::type* = 0);
const typename std::enable_if<std::is_same<T, std::string>::value>::type* = 0);
/**
* Return the default value of a matrix option, a tuple option, a
@@ -57,10 +58,10 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if_c<
const typename std::enable_if<
arma::is_arma_type<T>::value ||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
arma::mat>>::value>::type* /* junk */ = 0);
arma::mat>>::value>::type* = 0);
/**
* Return the default value of a model option (this returns the default
@@ -69,8 +70,8 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Return the default value of an option. This is the function that will be
@@ -24,12 +24,13 @@ namespace python {
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::disable_if<util::IsStdVector<T>>::type* /* junk */,
const typename boost::disable_if<data::HasSerialize<T>>::type* /* junk */,
const typename boost::disable_if<std::is_same<T, std::string>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* /* junk */,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* /* junk */,
const typename std::enable_if<!std::is_same<T,
std::string>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* /* junk */)
{
std::ostringstream oss;
if (std::is_same<T, bool>::value)
@@ -46,7 +47,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* /* junk */)
const typename std::enable_if<util::IsStdVector<T>::value>::type* /* junk */)
{
// Print each element in an array delimited by square brackets.
std::ostringstream oss;
@@ -89,7 +90,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T, std::string>>::type*)
const typename std::enable_if<std::is_same<T, std::string>::value>::type*)
{
const std::string& s = *boost::any_cast<std::string>(&data.value);
return "'" + s + "'";
@@ -102,7 +103,7 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& /* data */,
const typename boost::enable_if_c<
const typename std::enable_if<
arma::is_arma_type<T>::value ||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
arma::mat>>::value>::type* /* junk */)
@@ -134,8 +135,8 @@ std::string DefaultParamImpl(
template<typename T>
std::string DefaultParamImpl(
util::ParamData& /* data */,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::enable_if<data::HasSerialize<T>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<data::HasSerialize<T>::value>::type* /* junk */)
{
return "None";
}
+25 -22
View File
@@ -23,9 +23,9 @@ namespace python {
template<typename T>
inline std::string GetCythonType(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
{
return "unknown";
}
@@ -33,9 +33,9 @@ inline std::string GetCythonType(
template<>
inline std::string GetCythonType<int>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<int>>::type*,
const typename boost::disable_if<data::HasSerialize<int>>::type*,
const typename boost::disable_if<arma::is_arma_type<int>>::type*)
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*)
{
return "int";
}
@@ -43,9 +43,9 @@ inline std::string GetCythonType<int>(
template<>
inline std::string GetCythonType<double>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<double>>::type*,
const typename boost::disable_if<data::HasSerialize<double>>::type*,
const typename boost::disable_if<arma::is_arma_type<double>>::type*)
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*)
{
return "double";
}
@@ -53,9 +53,12 @@ inline std::string GetCythonType<double>(
template<>
inline std::string GetCythonType<std::string>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
const typename boost::disable_if<arma::is_arma_type<std::string>>::type*)
const typename std::enable_if<
!util::IsStdVector<std::string>::value>::type*,
const typename std::enable_if<
!data::HasSerialize<std::string>::value>::type*,
const typename std::enable_if<
!arma::is_arma_type<std::string>::value>::type*)
{
return "string";
}
@@ -63,9 +66,9 @@ inline std::string GetCythonType<std::string>(
template<>
inline std::string GetCythonType<size_t>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<size_t>>::type*,
const typename boost::disable_if<data::HasSerialize<size_t>>::type*,
const typename boost::disable_if<arma::is_arma_type<size_t>>::type*)
const typename std::enable_if<!util::IsStdVector<size_t>::value>::type*,
const typename std::enable_if<!data::HasSerialize<size_t>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<size_t>::value>::type*)
{
return "size_t";
}
@@ -73,9 +76,9 @@ inline std::string GetCythonType<size_t>(
template<>
inline std::string GetCythonType<bool>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<bool>>::type*,
const typename boost::disable_if<data::HasSerialize<bool>>::type*,
const typename boost::disable_if<arma::is_arma_type<bool>>::type*)
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*)
{
return "cbool";
}
@@ -83,7 +86,7 @@ inline std::string GetCythonType<bool>(
template<typename T>
inline std::string GetCythonType(
util::ParamData& d,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
{
return "vector[" + GetCythonType<typename T::value_type>(d) + "]";
}
@@ -91,7 +94,7 @@ inline std::string GetCythonType(
template<typename T>
inline std::string GetCythonType(
util::ParamData& d,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
std::string type = "Mat";
if (T::is_row)
@@ -105,8 +108,8 @@ inline std::string GetCythonType(
template<typename T>
inline std::string GetCythonType(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
return d.cppType + "*";
}
@@ -25,11 +25,11 @@ namespace python {
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
std::ostringstream oss;
oss << boost::any_cast<T>(data.value);
@@ -42,7 +42,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
{
const T& t = boost::any_cast<T>(data.value);
@@ -58,7 +58,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
// Get the matrix.
const T& matrix = boost::any_cast<T>(data.value);
@@ -74,8 +74,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
std::ostringstream oss;
oss << data.cppType << " model at " << boost::any_cast<T*>(data.value);
@@ -88,8 +88,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
// Get the matrix.
const T& tuple = boost::any_cast<T>(data.value);
@@ -23,84 +23,87 @@ namespace python {
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<>
inline std::string GetPrintableType<int>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<int>>::type*,
const typename boost::disable_if<data::HasSerialize<int>>::type*,
const typename boost::disable_if<arma::is_arma_type<int>>::type*,
const typename boost::disable_if<std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
const typename std::enable_if<!std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<>
inline std::string GetPrintableType<double>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<double>>::type*,
const typename boost::disable_if<data::HasSerialize<double>>::type*,
const typename boost::disable_if<arma::is_arma_type<double>>::type*,
const typename boost::disable_if<std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
const typename std::enable_if<!std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<>
inline std::string GetPrintableType<std::string>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
const typename boost::disable_if<arma::is_arma_type<std::string>>::type*,
const typename boost::disable_if<std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<
!util::IsStdVector<std::string>::value>::type*,
const typename std::enable_if<
!data::HasSerialize<std::string>::value>::type*,
const typename std::enable_if<
!arma::is_arma_type<std::string>::value>::type*,
const typename std::enable_if<!std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<>
inline std::string GetPrintableType<size_t>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<size_t>>::type*,
const typename boost::disable_if<data::HasSerialize<size_t>>::type*,
const typename boost::disable_if<arma::is_arma_type<size_t>>::type*,
const typename boost::disable_if<std::is_same<size_t,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<!util::IsStdVector<size_t>::value>::type*,
const typename std::enable_if<!data::HasSerialize<size_t>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<size_t>::value>::type*,
const typename std::enable_if<!std::is_same<size_t,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<>
inline std::string GetPrintableType<bool>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<bool>>::type*,
const typename boost::disable_if<data::HasSerialize<bool>>::type*,
const typename boost::disable_if<arma::is_arma_type<bool>>::type*,
const typename boost::disable_if<std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>>::type*);
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
const typename std::enable_if<!std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
template<typename T>
inline std::string GetPrintableType(
util::ParamData& d,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<typename T>
inline std::string GetPrintableType(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
template<typename T>
void GetPrintableType(util::ParamData& d,
@@ -22,11 +22,11 @@ namespace python {
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "unknown";
}
@@ -34,11 +34,11 @@ inline std::string GetPrintableType(
template<>
inline std::string GetPrintableType<int>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<int>>::type*,
const typename boost::disable_if<data::HasSerialize<int>>::type*,
const typename boost::disable_if<arma::is_arma_type<int>>::type*,
const typename boost::disable_if<std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
const typename std::enable_if<!std::is_same<int,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "int";
}
@@ -46,11 +46,11 @@ inline std::string GetPrintableType<int>(
template<>
inline std::string GetPrintableType<double>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<double>>::type*,
const typename boost::disable_if<data::HasSerialize<double>>::type*,
const typename boost::disable_if<arma::is_arma_type<double>>::type*,
const typename boost::disable_if<std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
const typename std::enable_if<!std::is_same<double,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "float";
}
@@ -58,11 +58,14 @@ inline std::string GetPrintableType<double>(
template<>
inline std::string GetPrintableType<std::string>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
const typename boost::disable_if<arma::is_arma_type<std::string>>::type*,
const typename boost::disable_if<std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<
!util::IsStdVector<std::string>::value>::type*,
const typename std::enable_if<
!data::HasSerialize<std::string>::value>::type*,
const typename std::enable_if<
!arma::is_arma_type<std::string>::value>::type*,
const typename std::enable_if<!std::is_same<std::string,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "str";
}
@@ -70,11 +73,11 @@ inline std::string GetPrintableType<std::string>(
template<>
inline std::string GetPrintableType<size_t>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<size_t>>::type*,
const typename boost::disable_if<data::HasSerialize<size_t>>::type*,
const typename boost::disable_if<arma::is_arma_type<size_t>>::type*,
const typename boost::disable_if<std::is_same<size_t,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<size_t>::value>::type*,
const typename std::enable_if<!data::HasSerialize<size_t>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<size_t>::value>::type*,
const typename std::enable_if<!std::is_same<size_t,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "int";
}
@@ -82,11 +85,11 @@ inline std::string GetPrintableType<size_t>(
template<>
inline std::string GetPrintableType<bool>(
util::ParamData& /* d */,
const typename boost::disable_if<util::IsStdVector<bool>>::type*,
const typename boost::disable_if<data::HasSerialize<bool>>::type*,
const typename boost::disable_if<arma::is_arma_type<bool>>::type*,
const typename boost::disable_if<std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
const typename std::enable_if<!std::is_same<bool,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "bool";
}
@@ -94,9 +97,9 @@ inline std::string GetPrintableType<bool>(
template<typename T>
inline std::string GetPrintableType(
util::ParamData& d,
const typename boost::enable_if<util::IsStdVector<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<util::IsStdVector<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "list of " + GetPrintableType<typename T::value_type>(d) + "s";
}
@@ -104,9 +107,9 @@ inline std::string GetPrintableType(
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::enable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
std::string type = "matrix";
if (std::is_same<typename T::elem_type, double>::value)
@@ -127,8 +130,8 @@ inline std::string GetPrintableType(
template<typename T>
inline std::string GetPrintableType(
util::ParamData& /* d */,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return "categorical matrix";
}
@@ -136,10 +139,10 @@ inline std::string GetPrintableType(
template<typename T>
inline std::string GetPrintableType(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
return d.cppType + "Type";
}
+5 -5
View File
@@ -26,8 +26,8 @@ template<typename T>
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)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// First, we have to parse the type. If we have something like, e.g.,
// 'LogisticRegression<>', we must convert this to 'LogisticRegression[T=*].'
@@ -53,8 +53,8 @@ template<typename T>
void ImportDecl(
util::ParamData& /* d */,
const size_t /* indent */,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0)
{
// Print nothing.
}
@@ -66,7 +66,7 @@ template<typename T>
void ImportDecl(
util::ParamData& /* d */,
const size_t /* indent */,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
// Print nothing.
}
+17 -14
View File
@@ -25,8 +25,8 @@ namespace python {
template<typename T>
void PrintClassDefn(
util::ParamData& /* d */,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0)
{
// Do nothing.
}
@@ -37,7 +37,7 @@ void PrintClassDefn(
template<typename T>
void PrintClassDefn(
util::ParamData& /* d */,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
// Do nothing.
}
@@ -48,8 +48,8 @@ void PrintClassDefn(
template<typename T>
void PrintClassDefn(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// First, we have to parse the type. If we have something like, e.g.,
// 'LogisticRegression<>', we must convert this to 'LogisticRegression[].'
@@ -63,11 +63,11 @@ void PrintClassDefn(
* cdef class <ModelType>Type:
* cdef <ModelType>* modelptr
* cdef public dict scrubbed_params
*
*
* def __cinit__(self):
* self.modelptr = new <ModelType>()
* self.scrubbed_params = dict()
*
*
* def __dealloc__(self):
* del self.modelptr
*
@@ -82,18 +82,18 @@ void PrintClassDefn(
*
* def _get_cpp_params(self):
* return SerializeOutJSON(self.modelptr, "<ModelType>")
*
*
* def _set_cpp_params(self, state):
* SerializeInJSON(self.modelptr, state, "<ModelType>")
*
*
* def get_cpp_params(self, return_str=False):
* params = self._get_cpp_params()
* return process_params_out(self, params, return_str=return_str)
*
*
* def set_cpp_params(self, params_dic):
* params_str = process_params_in(self, params_dic)
* self._set_cpp_params(params_str)
*
*
* @endcode
*/
std::cout << "cdef class " << strippedType << "Type:" << std::endl;
@@ -129,11 +129,14 @@ void PrintClassDefn(
std::cout << std::endl;
std::cout << " def get_cpp_params(self, return_str=False):" << std::endl;
std::cout << " params = self._get_cpp_params()" << std::endl;
std::cout << " return process_params_out(self, params, return_str=return_str)" << std::endl;
std::cout << " return process_params_out(self, params, "
<< "return_str=return_str)" << std::endl;
std::cout << std::endl;
std::cout << " def set_cpp_params(self, params_dic):" << std::endl;
std::cout << " params_str = process_params_in(self, params_dic)" << std::endl;
std::cout << " self._set_cpp_params(params_str.encode(\"utf-8\"))" << std::endl;
std::cout << " params_str = process_params_in(self, params_dic)"
<< std::endl;
std::cout << " self._set_cpp_params(params_str.encode(\"utf-8\"))"
<< std::endl;
std::cout << std::endl;
}
@@ -31,11 +31,11 @@ template<typename T>
void PrintInputProcessing(
util::ParamData& d,
const size_t indent,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
// The copy_all_inputs parameter must be handled first, and therefore is
// outside the scope of this code.
@@ -164,11 +164,11 @@ template<typename T>
void PrintInputProcessing(
util::ParamData& d,
const size_t indent,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0,
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -251,8 +251,8 @@ template<typename T>
void PrintInputProcessing(
util::ParamData& d,
const size_t indent,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -372,9 +372,9 @@ template<typename T>
void PrintInputProcessing(
util::ParamData& d,
const size_t indent,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// First, get the correct class name if needed.
std::string strippedType, printedType, defaultsType;
@@ -445,9 +445,9 @@ template<typename T>
void PrintInputProcessing(
util::ParamData& d,
const size_t indent,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
// The user should pass in a matrix type of some sort.
const std::string prefix(indent, ' ');
@@ -30,10 +30,10 @@ void PrintOutputProcessing(
util::ParamData& d,
const size_t indent,
const bool onlyOutput,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -86,7 +86,7 @@ void PrintOutputProcessing(
util::ParamData& d,
const size_t indent,
const bool onlyOutput,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -128,8 +128,8 @@ void PrintOutputProcessing(
util::ParamData& d,
const size_t indent,
const bool onlyOutput,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
{
const std::string prefix(indent, ' ');
@@ -170,8 +170,8 @@ void PrintOutputProcessing(
util::ParamData& d,
const size_t indent,
const bool onlyOutput,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// Get the type names we need to use.
std::string strippedType, printedType, defaultsType;
+4 -2
View File
@@ -80,8 +80,10 @@ void PrintPYX(const util::BindingDetails& doc,
cout << "from io cimport EnableVerbose, DisableVerbose, DisableBacktrace, "
<< "ResetTimers, EnableTimers" << endl;
cout << "from matrix_utils import to_matrix, to_matrix_with_info" << endl;
cout << "from preprocess_json_params import process_params_out, process_params_in" << endl;
cout << "from serialization cimport SerializeIn, SerializeOut, SerializeOutJSON, SerializeInJSON" << endl;
cout << "from preprocess_json_params import process_params_out, "
<< "process_params_in" << endl;
cout << "from serialization cimport SerializeIn, SerializeOut, "
<< "SerializeOutJSON, SerializeInJSON" << endl;
cout << endl;
cout << "import numpy as np" << endl;
cout << "cimport numpy as np" << endl;
@@ -25,11 +25,11 @@ namespace python {
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Return a string representing the command-line type of a vector.
@@ -62,8 +62,8 @@ std::string PrintTypeDoc(
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Print the command-line type of an option into a string.
@@ -24,11 +24,11 @@ namespace python {
template<typename T>
std::string PrintTypeDoc(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::disable_if<util::IsStdVector<T>>::type*,
const typename boost::disable_if<data::HasSerialize<T>>::type*,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
{
// A flag type.
if (std::is_same<T, bool>::value)
@@ -150,8 +150,8 @@ std::string PrintTypeDoc(
template<typename T>
std::string PrintTypeDoc(
util::ParamData& /* data */,
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
const typename boost::enable_if<data::HasSerialize<T>>::type*)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
{
return "An mlpack model pointer. This type can be pickled to or from disk, "
"and internally holds a pointer to C++ memory containing the mlpack "
@@ -21,8 +21,8 @@ namespace tests {
template<typename T>
void DeleteAllocatedMemoryImpl(
util::ParamData& /* d */,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
{
// Do nothing.
}
@@ -30,7 +30,7 @@ void DeleteAllocatedMemoryImpl(
template<typename T>
void DeleteAllocatedMemoryImpl(
util::ParamData& /* d */,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
// Do nothing.
}
@@ -38,8 +38,8 @@ void DeleteAllocatedMemoryImpl(
template<typename T>
void DeleteAllocatedMemoryImpl(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// Delete the allocated memory (hopefully we actually own it).
delete *boost::any_cast<T*>(&d.value);
@@ -22,8 +22,8 @@ namespace tests {
template<typename T>
void* GetAllocatedMemory(
util::ParamData& /* d */,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
{
return NULL;
}
@@ -31,7 +31,7 @@ void* GetAllocatedMemory(
template<typename T>
void* GetAllocatedMemory(
util::ParamData& /* d */,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
{
return NULL;
}
@@ -39,8 +39,8 @@ void* GetAllocatedMemory(
template<typename T>
void* GetAllocatedMemory(
util::ParamData& d,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
{
// Here we have a model; return its memory location.
return *boost::any_cast<T*>(&d.value);
@@ -27,11 +27,11 @@ namespace tests {
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Print a vector option, with spaces between it.
@@ -39,7 +39,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0);
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
/**
* Print a matrix option (this just prints the filename).
@@ -47,7 +47,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0);
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
/**
* Print a serializable class option (this just prints the filename).
@@ -55,8 +55,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
/**
* Print a mapped matrix option (this just prints the filename).
@@ -64,8 +64,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
/**
* Print an option into a std::string. This should print a short, one-line
@@ -22,11 +22,11 @@ namespace tests {
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::disable_if<util::IsStdVector<T>>::type* /* junk */,
const typename boost::disable_if<data::HasSerialize<T>>::type* /* junk */,
const typename boost::disable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<!util::IsStdVector<T>::value>::type* /* junk */,
const typename std::enable_if<!data::HasSerialize<T>::value>::type* /* junk */,
const typename std::enable_if<!std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* /* junk */)
{
std::ostringstream oss;
oss << boost::any_cast<T>(data.value);
@@ -37,7 +37,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::enable_if<util::IsStdVector<T>>::type* /* junk */)
const typename std::enable_if<util::IsStdVector<T>::value>::type* /* junk */)
{
const T& t = boost::any_cast<T>(data.value);
@@ -51,7 +51,7 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& /* data */,
const typename boost::enable_if<arma::is_arma_type<T>>::type* /* junk */)
const typename std::enable_if<arma::is_arma_type<T>::value>::type* /* junk */)
{
return "matrix type";
}
@@ -60,8 +60,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& data,
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
const typename boost::enable_if<data::HasSerialize<T>>::type* /* junk */)
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* /* junk */,
const typename std::enable_if<data::HasSerialize<T>::value>::type* /* junk */)
{
// Extract the string from the tuple that's being held.
std::ostringstream oss;
@@ -73,8 +73,8 @@ std::string GetPrintableParam(
template<typename T>
std::string GetPrintableParam(
util::ParamData& /* data */,
const typename boost::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>>::type* /* junk */)
const typename std::enable_if<std::is_same<T,
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* /* junk */)
{
return "matrix/DatatsetInfo tuple";
}
+7 -3
View File
@@ -34,7 +34,7 @@ namespace data /** Functions to load and save matrices and models. */ {
*
* - CSV (arma::csv_ascii), denoted by .csv, or optionally .txt
* - TSV (arma::raw_ascii), denoted by .tsv, .csv, or .txt
* - ASCII (arma::raw_ascii), denoted by .json
* - ASCII (arma::raw_ascii), denoted by .txt
* - Armadillo ASCII (arma::arma_ascii), also denoted by .txt
* - PGM (arma::pgm_binary), denoted by .pgm
* - PPM (arma::ppm_binary), denoted by .ppm
@@ -273,8 +273,12 @@ bool Load(const std::string& filename,
* mlpack requires column-major matrices, this should be left at its default
* value of 'true'.
*
* The DatasetMapper object passed to this function will be re-created, so any
* mappings from previous loads will be lost.
* If the given `info` has already been used with a different `data::Load()`
* call where the dataset has the same dimensionality, then the mappings and
* dimension types inside of `info` will be *re-used*. If the given `info` is a
* new `DatasetMapper` object (e.g. its dimensionality is 0), then new mappings
* will be created. If the given `info` has a different dimensionality of data
* than what is present in `filename`, an exception will be thrown.
*
* @param filename Name of file to load.
* @param matrix Matrix to load contents of file into.
+27 -3
View File
@@ -96,7 +96,20 @@ class LoadCSV
{
++rows;
}
info = DatasetMapper<MapPolicy>(rows);
// Reset the DatasetInfo object, if needed.
if (info.Dimensionality() == 0)
{
info.SetDimensionality(rows);
}
else if (info.Dimensionality() != rows)
{
std::ostringstream oss;
oss << "data::LoadCSV(): given DatasetInfo has dimensionality "
<< info.Dimensionality() << ", but data has dimensionality "
<< rows;
throw std::invalid_argument(oss.str());
}
// Now, jump back to the beginning of the file.
inFile.clear();
@@ -179,8 +192,19 @@ class LoadCSV
qi::parse(line.begin(), line.end(),
stringRule[findRowSize] % delimiterRule);
// Now that we know the dimensionality, initialize the DatasetMapper.
info.SetDimensionality(rows);
// Reset the DatasetInfo object, if needed.
if (info.Dimensionality() == 0)
{
info.SetDimensionality(rows);
}
else if (info.Dimensionality() != rows)
{
std::ostringstream oss;
oss << "data::LoadCSV(): given DatasetInfo has dimensionality "
<< info.Dimensionality() << ", but data has dimensionality "
<< rows;
throw std::invalid_argument(oss.str());
}
}
// If we need to do a first pass for the DatasetMapper, do it.
-7
View File
@@ -15,15 +15,8 @@
// In case it hasn't already been included.
#include "load.hpp"
#include <algorithm>
#include <mlpack/core/util/timers.hpp>
#include "extension.hpp"
#include <boost/tokenizer.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <cereal/archives/xml.hpp>
#include <cereal/archives/binary.hpp>
#include <cereal/archives/json.hpp>
+1 -1
View File
@@ -32,7 +32,7 @@ namespace data /** Functions to load and save matrices. */ {
* The supported types of files are the same as found in Armadillo:
*
* - CSV (arma::csv_ascii), denoted by .csv, or optionally .txt
* - ASCII (arma::raw_ascii), denoted by .json
* - ASCII (arma::raw_ascii), denoted by .txt
* - Armadillo ASCII (arma::arma_ascii), also denoted by .txt
* - PGM (arma::pgm_binary), denoted by .pgm
* - PPM (arma::ppm_binary), denoted by .ppm
@@ -54,7 +54,7 @@ template<typename MetricType = metric::EuclideanDistance,
class RectangleTree
{
// The metric *must* be the euclidean distance.
static_assert(boost::is_same<MetricType, metric::EuclideanDistance>::value,
static_assert(std::is_same<MetricType, metric::EuclideanDistance>::value,
"RectangleTree: MetricType must be metric::EuclideanDistance.");
public:
@@ -1,8 +1,8 @@
# Define the files we need to compile.
# Anything not in this list will not be compiled into mlpack.
set(SOURCES
inception_score
inception_score_impl
inception_score.hpp
inception_score_impl.hpp
)
# Add directory name to sources.
@@ -18,6 +18,8 @@ set(SOURCES
batch_norm_impl.hpp
bilinear_interpolation.hpp
bilinear_interpolation_impl.hpp
channel_shuffle.hpp
channel_shuffle_impl.hpp
concat.hpp
concat_impl.hpp
concat_performance.hpp
@@ -234,7 +234,7 @@ void BatchNorm<InputDataType, OutputDataType>::serialize(
if (cereal::is_loading<Archive>())
{
weights.set_size(size + size, 1);
loading = false;
loading = true;
}
ar(CEREAL_NVP(eps));
@@ -0,0 +1,155 @@
/**
* @file methods/ann/layer/channel_shuffle.hpp
* @author Abhinav Anand
*
* mlpack is free software; you may redistribute it and/or modify it under the
* terms of the 3-clause BSD license. You should have received a copy of the
* 3-clause BSD license along with mlpack. If not, see
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
*/
#ifndef MLPACK_METHODS_ANN_LAYER_CHANNEL_SHUFFLE_HPP
#define MLPACK_METHODS_ANN_LAYER_CHANNEL_SHUFFLE_HPP
#include <mlpack/prereqs.hpp>
namespace mlpack {
namespace ann /** Artificial Neural Network. */ {
/**
* Definition and implementation of the Channel Shuffle Layer.
*
* Channel Shuffle divides the channels/units in a tensor into groups
* and rearrange while keeping the original tensor shape.
*
* For more information, refer to the following paper,
*
* @code
* @article{zhang2018shufflenet,
* author = {Xiangyu Zhang, Xinyu Zhou, Mengxiao Lin, Jian Sun and
* Megvii Inc},
* title = {Shufflenet: An extremely efficient convolutional neural
* network for mobile devices},
* year = {2018},
* url = {https://arxiv.org/pdf/1707.01083},
* }
* @endcode
*
* @tparam InputDataType Type of the input data (arma::colvec, arma::mat,
* arma::sp_mat or arma::cube).
* @tparam OutputDataType Type of the output data (arma::colvec, arma::mat,
* arma::sp_mat or arma::cube).
*/
template <
typename InputDataType = arma::mat,
typename OutputDataType = arma::mat
>
class ChannelShuffle
{
public:
//! Create the Channel Shuffle object.
ChannelShuffle();
/**
* The constructor for the Channel Shuffle.
*
* @param inRowSize Number of input rows.
* @param inColSize Number of input columns.
* @param depth Number of input slices.
* @param group Number of groups for shuffling channels.
*/
ChannelShuffle(const size_t inRowSize,
const size_t inColSize,
const size_t depth,
const size_t groupCount);
/**
* Forward pass through the layer.
*
* @param input The input matrix.
* @param output The resulting interpolated output matrix.
*/
template<typename eT>
void Forward(const arma::Mat<eT>& input, arma::Mat<eT>& output);
/**
* Ordinary feed backward pass of a neural network, calculating the function
* f(x) by propagating x backwards through f. Using the results from the feed
* forward pass. Since the layer does not have any learn-able parameters,
* we just have to down-sample the gradient to make its size compatible with
* the input size.
*
* @param * (input) The input matrix.
* @param gradient The computed backward gradient.
* @param output The resulting down-sampled output.
*/
template<typename eT>
void Backward(const arma::Mat<eT>& /*input*/,
const arma::Mat<eT>& gradient,
arma::Mat<eT>& output);
//! Get the output parameter.
OutputDataType const& OutputParameter() const { return outputParameter; }
//! Modify the output parameter.
OutputDataType& OutputParameter() { return outputParameter; }
//! Get the delta.
OutputDataType const& Delta() const { return delta; }
//! Modify the delta.
OutputDataType& Delta() { return delta; }
//! Get the row size of the input.
size_t const& InRowSize() const { return inRowSize; }
//! Modify the row size of the input.
size_t& InRowSize() { return inRowSize; }
//! Get the column size of the input.
size_t const& InColSize() const { return inColSize; }
//! Modify the column size of the input.
size_t& InColSize() { return inColSize; }
//! Get the depth of the input.
size_t const& InDepth() const { return depth; }
//! Modify the depth of the input.
size_t& InDepth() { return depth; }
//! Get the number of groups the channels is divided into.
size_t const& InGroupCount() const { return groupCount; }
//! Modify the number of groups the channels is divided into.
size_t& InGroupCount() { return groupCount; }
//! Get the shape of the input.
size_t InputShape() const
{
return inRowSize;
}
/**
* Serialize the layer.
*/
template<typename Archive>
void serialize(Archive& ar, const uint32_t /* version */);
private:
//! Locally stored row size of the input.
size_t inRowSize;
//! Locally stored column size of the input.
size_t inColSize;
//! Locally stored depth of the input.
size_t depth;
//! Locally stored the number of groups the channels is divided into.
size_t groupCount;
//! Locally stored number of input points.
size_t batchSize;
//! Locally-stored delta object.
OutputDataType delta;
//! Locally-stored output parameter object.
OutputDataType outputParameter;
}; // class ChannelShuffle
} // namespace ann
} // namespace mlpack
// Include implementation.
#include "channel_shuffle_impl.hpp"
#endif
@@ -0,0 +1,137 @@
/**
* @file methods/ann/layer/channe_shuffle_impl.hpp
* @author Abhinav Anand
*
* Implementation of the channel shuffle function as an individual layer.
*
* mlpack is free software; you may redistribute it and/or modify it under the
* terms of the 3-clause BSD license. You should have received a copy of the
* 3-clause BSD license along with mlpack. If not, see
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
*/
#ifndef MLPACK_METHODS_ANN_LAYER_CHANNEL_SHUFFLE_IMPL_HPP
#define MLPACK_METHODS_ANN_LAYER_CHANNEL_SHUFFLE_IMPL_HPP
// In case it hasn't yet been included.
#include "channel_shuffle.hpp"
namespace mlpack {
namespace ann /** Artificial Neural Network. */ {
template<typename InputDataType, typename OutputDataType>
ChannelShuffle<InputDataType, OutputDataType>::
ChannelShuffle():
inRowSize(0),
inColSize(0),
depth(0),
groupCount(0),
batchSize(0)
{
// Nothing to do here.
}
template<typename InputDataType, typename OutputDataType>
ChannelShuffle<InputDataType, OutputDataType>::
ChannelShuffle(
const size_t inRowSize,
const size_t inColSize,
const size_t depth,
const size_t groupCount):
inRowSize(inRowSize),
inColSize(inColSize),
depth(depth),
groupCount(groupCount),
batchSize(0)
{
if (depth % groupCount != 0)
{
Log::Fatal << "Number of channels must be divisible by groupCount!" << std::endl;
}
}
template<typename InputDataType, typename OutputDataType>
template<typename eT>
void ChannelShuffle<InputDataType, OutputDataType>::Forward(
const arma::Mat<eT>& input, arma::Mat<eT>& output)
{
batchSize = input.n_cols;
if (output.is_empty())
output.set_size(inRowSize * inColSize * depth, batchSize);
else
{
assert(output.n_rows == inRowSize * inColSize * depth);
assert(output.n_cols == batchSize);
}
arma::cube inputAsCube(const_cast<arma::Mat<eT>&>(input).memptr(),
inRowSize, inColSize, depth * batchSize, false, false);
arma::cube outputAsCube(output.memptr(), inRowSize, inColSize,
depth * batchSize, false, true);
const size_t groupSize= depth / groupCount;
size_t outChannelIdx = 0;
for (size_t k = 0; k < batchSize; ++k)
{
for (size_t i = 0; i < groupSize; ++i)
{
for (size_t g = 0; g < groupCount; ++g, ++outChannelIdx)
{
size_t inChannelIdx = k * batchSize + g * groupSize + i;
outputAsCube.slice(outChannelIdx) = inputAsCube.slice(inChannelIdx);
}
}
}
}
template<typename InputDataType, typename OutputDataType>
template<typename eT>
void ChannelShuffle<InputDataType, OutputDataType>::Backward(
const arma::Mat<eT>& /*input*/,
const arma::Mat<eT>& gradient,
arma::Mat<eT>& output)
{
if (output.is_empty())
output.set_size(inRowSize * inColSize * depth, batchSize);
else
{
assert(output.n_rows == inRowSize * inColSize * depth);
assert(output.n_cols == batchSize);
}
arma::cube gradientAsCube(((arma::Mat<eT>&) gradient).memptr(), inColSize,
inColSize, depth * batchSize, false, false);
arma::cube outputAsCube(output.memptr(), inRowSize, inColSize,
depth * batchSize, false, true);
const size_t groupSize= depth / groupCount;
size_t gradientChannelIdx = 0;
for (size_t k = 0; k < batchSize; ++k)
{
for (size_t i = 0; i < groupSize; ++i)
{
for (size_t g = 0; g < groupCount; ++g, ++gradientChannelIdx)
{
size_t outChannelIdx = k * batchSize + g * groupSize + i;
outputAsCube.slice(outChannelIdx) = gradientAsCube.slice(gradientChannelIdx);
}
}
}
}
template<typename InputDataType, typename OutputDataType>
template<typename Archive>
void ChannelShuffle<InputDataType, OutputDataType>::serialize(
Archive& ar, const uint32_t /* version */)
{
ar(CEREAL_NVP(inRowSize));
ar(CEREAL_NVP(inColSize));
ar(CEREAL_NVP(depth));
}
} // namespace ann
} // namespace mlpack
#endif

Some files were not shown because too many files have changed in this diff Show More