mlpack
|
#include <mlpack/prereqs.hpp>
#include "get_arma_type.hpp"
#include "get_numpy_type.hpp"
#include "get_numpy_type_char.hpp"
#include "get_cython_type.hpp"
#include "strip_type.hpp"
Go to the source code of this file.
Namespaces | |
mlpack | |
Linear algebra utility functions, generally performed on matrices or vectors. | |
Functions | |
template<typename T > | |
void | mlpack::bindings::python::PrintInputProcessing (util::ParamData &d, const size_t indent, 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) |
Print input processing for a standard option type. More... | |
template<typename T > | |
void | mlpack::bindings::python::PrintInputProcessing (util::ParamData &d, const size_t indent, 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) |
Print input processing for a vector type. More... | |
template<typename T > | |
void | mlpack::bindings::python::PrintInputProcessing (util::ParamData &d, const size_t indent, const typename std::enable_if<!util::IsStdVector< T >::value >::type *=0, const typename std::enable_if< arma::is_arma_type< T >::value >::type *=0) |
Print input processing for a matrix type. More... | |
template<typename T > | |
void | mlpack::bindings::python::PrintInputProcessing (util::ParamData &d, const size_t indent, 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) |
Print input processing for a serializable type. More... | |
template<typename T > | |
void | mlpack::bindings::python::PrintInputProcessing (util::ParamData &d, const size_t indent, 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) |
Print input processing for a matrix/DatasetInfo type. More... | |
template<typename T > | |
void | mlpack::bindings::python::PrintInputProcessing (util::ParamData &d, const void *input, void *) |
Given parameter information and the current number of spaces for indentation, print the code to process the input to cout. More... | |
Print input processing for a Python binding option.
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.
void mlpack::bindings::python::PrintInputProcessing | ( | util::ParamData & | d, |
const size_t | indent, | ||
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 |
||
) |
Print input processing for a standard option type.
This gives us code like:
if param_name is not None: if isinstance(param_name, int): SetParam[int](<const string> 'param_name', param_name) IO.SetPassed(<const string> 'param_name') else: raise TypeError("'param_name' must have type 'list'!")
void mlpack::bindings::python::PrintInputProcessing | ( | util::ParamData & | d, |
const size_t | indent, | ||
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 |
||
) |
Print input processing for a vector type.
This gives us code like: if param_name is not None: if isinstance(param_name, list): if len(param_name) > 0: if isinstance(param_name[0], str): SetParam[vector[string]](<const string> 'param_name', param_name) IO.SetPassed(<const string> 'param_name') else: raise TypeError("'param_name' must have type 'list of strs'!") else: raise TypeError("'param_name' must have type 'list'!")
void mlpack::bindings::python::PrintInputProcessing | ( | util::ParamData & | d, |
const size_t | indent, | ||
const typename std::enable_if<!util::IsStdVector< T >::value >::type * | = 0 , |
||
const typename std::enable_if< arma::is_arma_type< T >::value >::type * | = 0 |
||
) |
Print input processing for a matrix type.
This gives us code like:
if param_name is not None: param_name_tuple = to_matrix(param_name) if param_name_tuple[0].shape[0] == 1 or param_name_tuple[0].shape[1] == 1: param_name_tuple[0].shape = (param_name_tuple[0].size,) param_name_mat = arma_numpy.numpy_to_mat_s(param_name_tuple[0], param_name_tuple[1]) SetParam[mat](<const string> 'param_name', dereference(param_name_mat)) IO.SetPassed(<const string> 'param_name')
void mlpack::bindings::python::PrintInputProcessing | ( | util::ParamData & | d, |
const size_t | indent, | ||
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 |
||
) |
Print input processing for a serializable type.
This gives us code like:
if param_name is not None: try: SetParamPtr[Model]('param_name', (<ModelType?> param_name).modelptr, IO.HasParam('copy_all_inputs')) except TypeError as e: if type(param_name).__name__ == "ModelType": SetParamPtr[Model]('param_name', (<ModelType> param_name).modelptr, IO.HasParam('copy_all_inputs')) else: raise e IO.SetPassed(<const string> 'param_name')
void mlpack::bindings::python::PrintInputProcessing | ( | util::ParamData & | d, |
const size_t | indent, | ||
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 |
||
) |
Print input processing for a matrix/DatasetInfo type.
We want to generate code like the following:
if param_name is not None: param_name_tuple = to_matrix_with_info(param_name) if len(param_name_tuple[0].shape) < 2: param_name_tuple[0].shape = (param_name_tuple[0].size,) param_name_mat = arma_numpy.numpy_to_matrix_d(param_name_tuple[0]) SetParamWithInfo[mat](<const string> 'param_name', dereference(param_name_mat), ¶m_name_tuple[1][0]) IO.SetPassed(<const string> 'param_name')
void mlpack::bindings::python::PrintInputProcessing | ( | util::ParamData & | d, |
const void * | input, | ||
void * | |||
) |
Given parameter information and the current number of spaces for indentation, print the code to process the input to cout.
This code assumes that data.input is true, and should not be called when data.input is false.
The number of spaces to indent should be passed through the input pointer.
d | Parameter data struct. |
input | Pointer to size_t holding the indentation. |
* | (output) Unused parameter. |