mlpack::bindings::python Namespace Reference

Classes

class  PyOption
 The Python option class. More...

 

Functions

template<typename... Args>
std::string CallMethod (const std::string &bindingName, const std::string &objectName, const std::string &methodName, Args... args)
 
template<typename... Args>
std::string CreateObject (const std::string &bindingName, const std::string &objectName, const std::string &groupName, Args... args)
 
std::string CreateObject (const std::string &bindingName, const std::string &objectName, const std::string &groupName)
 
template
<
typename
T
>
void DefaultParam (util::ParamData &data, const void *, void *output)
 Return the default value of an option. More...

 
template
<
typename
T
>
std::string DefaultParamImpl (util::ParamData &data, 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 an option. More...

 
template
<
typename
T
>
std::string DefaultParamImpl (util::ParamData &data, const typename std::enable_if< util::IsStdVector< T >::value >::type *=0)
 Return the default value of a vector option. More...

 
template
<
typename
T
>
std::string DefaultParamImpl (util::ParamData &data, const typename std::enable_if< std::is_same< T, std::string >::value >::type *=0)
 Return the default value of a string option. More...

 
template
<
typename
T
>
std::string DefaultParamImpl (util::ParamData &data, 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)
 Return the default value of a matrix option, a tuple option, a serializable option, or a string option (this returns the default filename, or '' if the default is no file). More...

 
template
<
typename
T
>
std::string DefaultParamImpl (util::ParamData &data, 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 a model option (this returns the default filename, or '' if the default is no file). More...

 
template
<
typename
T
>
std::string GetArmaType ()
 This is used for arma::Mat<> types; it will return "mat" for matrices, "row" for row vectors, and "col" for column vectors. More...

 
std::string GetBindingName (const std::string &bindingName)
 Given the name of a binding, print its Python name. More...

 
std::string GetClassName (const std::string &groupName)
 
template
<
typename
T
>
std::string GetCythonType (util::ParamData &, 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)
 
template
<
typename
T
>
std::string GetCythonType (util::ParamData &d, const typename std::enable_if< util::IsStdVector< T >::value >::type *=0)
 
template
<
typename
T
>
std::string GetCythonType (util::ParamData &d, const typename std::enable_if< arma::is_arma_type< T >::value >::type *=0)
 
template
<
typename
T
>
std::string GetCythonType (util::ParamData &d, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0, const typename std::enable_if< data::HasSerialize< T >::value >::type *=0)
 
template
<
>
std::string GetCythonType< bool > (util::ParamData &, 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 *)
 
template
<
>
std::string GetCythonType< double > (util::ParamData &, 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 *)
 
template
<
>
std::string GetCythonType< int > (util::ParamData &, 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 *)
 
template
<
>
std::string GetCythonType< size_t > (util::ParamData &, 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 *)
 
template
<
>
std::string GetCythonType< std::string > (util::ParamData &, 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 *)
 
std::string GetDataset (const std::string &datasetName, const std::string &url)
 
std::string GetMappedName (const std::string &methodName)
 
std::vector< std::string > GetMethods (const std::string &validMethods)
 
template
<
typename
T
>
std::string GetNumpyType ()
 
template
<
>
std::string GetNumpyType< double > ()
 
template
<
>
std::string GetNumpyType< size_t > ()
 
template
<
typename
T
>
std::string GetNumpyTypeChar ()
 
template
<
>
std::string GetNumpyTypeChar< arma::Col< size_t > > ()
 
template
<
>
std::string GetNumpyTypeChar< arma::mat > ()
 
template
<
>
std::string GetNumpyTypeChar< arma::Mat< size_t > > ()
 
template
<
>
std::string GetNumpyTypeChar< arma::Row< size_t > > ()
 
template
<
>
std::string GetNumpyTypeChar< arma::rowvec > ()
 
template
<
>
std::string GetNumpyTypeChar< arma::vec > ()
 
template
<
typename
T
>
void GetParam (util::ParamData &d, const void *, void *output)
 All Python binding types are exactly what is held in the ParamData, so no special handling is necessary. More...

 
template
<
typename
T
>
std::string GetPrintableParam (util::ParamData &data, 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 an option of a simple type. More...

 
template
<
typename
T
>
std::string GetPrintableParam (util::ParamData &data, const typename std::enable_if< util::IsStdVector< T >::value >::type *=0)
 Print a vector option, with spaces between it. More...

 
template
<
typename
T
>
std::string GetPrintableParam (util::ParamData &data, const typename std::enable_if< arma::is_arma_type< T >::value >::type *=0)
 Print a matrix option (this prints its size). More...

 
template
<
typename
T
>
std::string GetPrintableParam (util::ParamData &data, 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 serializable class option (this prints the class name). More...

 
template
<
typename
T
>
std::string GetPrintableParam (util::ParamData &data, const typename std::enable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>::value >::type *=0)
 Print a combination DatasetInfo/matrix parameter. More...

 
template
<
typename
T
>
void GetPrintableParam (util::ParamData &data, const void *, void *output)
 Print an option into a std::string. More...

 
template
<
typename
T
>
std::string GetPrintableType (util::ParamData &, 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
<
typename
T
>
std::string GetPrintableType (util::ParamData &d, 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
>
std::string GetPrintableType (util::ParamData &, 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
>
std::string GetPrintableType (util::ParamData &, const typename std::enable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>::value >::type *=0)
 
template
<
typename
T
>
std::string GetPrintableType (util::ParamData &d, 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, const void *, void *output)
 
template
<
>
std::string GetPrintableType< bool > (util::ParamData &, 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
<
>
std::string GetPrintableType< double > (util::ParamData &, 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
<
>
std::string GetPrintableType< int > (util::ParamData &, 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
<
>
std::string GetPrintableType< size_t > (util::ParamData &, 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
<
>
std::string GetPrintableType< std::string > (util::ParamData &, 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 *)
 
std::string GetValidName (const std::string &paramName)
 
bool IgnoreCheck (const std::string &bindingName, const std::string &paramName)
 Print whether or not we should ignore a check on the given parameter. More...

 
bool IgnoreCheck (const std::string &bindingName, const std::vector< std::string > &constraints)
 Print whether or not we should ignore a check on the given set of constraints. More...

 
bool IgnoreCheck (const std::string &bindingName, const std::vector< std::pair< std::string, bool >> &constraints, const std::string &paramName)
 Print whether or not we should ignore a check on the given set of constraints. More...

 
template
<
typename
T
>
void ImportDecl (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)
 For a serializable type, print a cppclass definition. More...

 
template
<
typename
T
>
void ImportDecl (util::ParamData &, const size_t, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0, const typename std::enable_if<!data::HasSerialize< T >::value >::type *=0)
 For a non-serializable type, print nothing. More...

 
template
<
typename
T
>
void ImportDecl (util::ParamData &, const size_t, const typename std::enable_if< arma::is_arma_type< T >::value >::type *=0)
 For a matrix type, print nothing. More...

 
template
<
typename
T
>
void ImportDecl (util::ParamData &d, const void *indent, void *)
 Print the cppclass definition for a serializable model; print nothing for a non-serializable type. More...

 
std::string ImportExtLib ()
 
std::string ImportSplit ()
 
std::string ImportThis (const std::string &groupName)
 
template
<
typename
T
>
bool IsSerializable (util::ParamData &, const typename boost::disable_if< data::HasSerialize< T >>::type *=0)
 
template
<
typename
T
>
bool IsSerializable (util::ParamData &, const typename boost::enable_if< data::HasSerialize< T >>::type *=0)
 
template
<
typename
T
>
void IsSerializable (util::ParamData &data, const void *, void *output)
 
std::string ParamString (const std::string &paramName)
 Given the parameter name, determine what it would actually be when passed to the command line. More...

 
template
<
typename
T
>
void PrintClassDefn (util::ParamData &, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0, const typename std::enable_if<!data::HasSerialize< T >::value >::type *=0)
 Non-serializable models don't require any special definitions, so this prints nothing. More...

 
template
<
typename
T
>
void PrintClassDefn (util::ParamData &, const typename std::enable_if< arma::is_arma_type< T >::value >::type *=0)
 Matrices don't require any special definitions, so this prints nothing. More...

 
template
<
typename
T
>
void PrintClassDefn (util::ParamData &d, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0, const typename std::enable_if< data::HasSerialize< T >::value >::type *=0)
 Serializable models require a special class definition. More...

 
template
<
typename
T
>
void PrintClassDefn (util::ParamData &d, const void *, void *)
 Print the class definition to stdout. More...

 
std::string PrintDataset (const std::string &datasetName)
 Given the name of a matrix, print it. More...

 
std::string PrintDefault (const std::string &bindingName, const std::string &paramName)
 Given a parameter name, print its corresponding default value. More...

 
template
<
typename
T
>
void PrintDefn (util::ParamData &d, const void *, void *)
 Print the definition for a Python binding parameter to stdout. More...

 
template
<
typename
T
>
void PrintDoc (util::ParamData &d, const void *input, void *)
 Print the docstring documentation for a given parameter. More...

 
std::string PrintImport (const std::string &bindingName)
 Print any import information for the Python binding. More...

 
std::string PrintInputOptionInfo ()
 Print any special information about input options. More...

 
std::string PrintInputOptions (util::Params &params, bool onlyHyperParams, bool onlyMatrixParams)
 
template<typename T , typename... Args>
std::string PrintInputOptions (util::Params &params, bool onlyHyperParams, bool onlyMatrixParams, const std::string &paramName, const T &value, Args... args)
 Print an input option. More...

 
template
<
typename
T
>
void 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 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 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 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 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 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...

 
std::string PrintModel (const std::string &modelName)
 Given the name of a model, print it. More...

 
std::string PrintOutputOptionInfo ()
 Print any special information about output options. More...

 
std::string PrintOutputOptions (util::Params &params)
 
template<typename T , typename... Args>
std::string PrintOutputOptions (util::Params &params, const std::string &paramName, const T &value, Args... args)
 
template
<
typename
T
>
void PrintOutputProcessing (util::Params &, util::ParamData &d, const size_t indent, const bool onlyOutput, 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 output processing for a regular parameter type. More...

 
template
<
typename
T
>
void PrintOutputProcessing (util::Params &, util::ParamData &d, const size_t indent, const bool onlyOutput, const typename std::enable_if< arma::is_arma_type< T >::value >::type *=0)
 Print output processing for a matrix type. More...

 
template
<
typename
T
>
void PrintOutputProcessing (util::Params &, util::ParamData &d, const size_t indent, const bool onlyOutput, const typename std::enable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>::value >::type *=0)
 Print output processing for a dataset info / matrix combination. More...

 
template
<
typename
T
>
void PrintOutputProcessing (util::Params &params, util::ParamData &d, const size_t indent, const bool onlyOutput, 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 output processing for a serializable model. More...

 
template
<
typename
T
>
void PrintOutputProcessing (util::ParamData &d, const void *input, void *)
 Given parameter information and the current number of spaces for indentation, print the code to process the output to cout. More...

 
void PrintPYX (const util::BindingDetails &doc, const std::string &mainFilename, const std::string &functionName)
 Given a list of parameter definition and program documentation, print a generated .pyx file to stdout. More...

 
template
<
typename
T
>
std::string PrintTypeDoc (util::ParamData &data, 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 an option. More...

 
template
<
typename
T
>
std::string PrintTypeDoc (util::ParamData &data, const typename std::enable_if< util::IsStdVector< T >::value >::type *=0)
 Return a string representing the command-line type of a vector. More...

 
template
<
typename
T
>
std::string PrintTypeDoc (util::ParamData &data, const typename std::enable_if< arma::is_arma_type< T >::value >::type *=0)
 Return a string representing the command-line type of a matrix option. More...

 
template
<
typename
T
>
std::string PrintTypeDoc (util::ParamData &data, 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 matrix tuple option. More...

 
template
<
typename
T
>
std::string PrintTypeDoc (util::ParamData &data, 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 a string representing the command-line type of a model. More...

 
template
<
typename
T
>
void PrintTypeDoc (util::ParamData &data, const void *, void *output)
 Print the command-line type of an option into a string. More...

 
template
<
typename
T
>
std::string PrintValue (const T &value, bool quotes)
 Given a parameter type, print the corresponding value. More...

 
template
<
>
std::string PrintValue (const bool &value, bool quotes)
 
void PrintWrapperPY (const std::string &category, const std::string &groupName, const std::string &validMethods)
 
template<typename... Args>
std::string ProgramCall (const std::string &programName, Args... args)
 Given a name of a binding and a variable number of arguments (and their contents), print the corresponding function call. More...

 
std::string ProgramCall (util::Params &p, const std::string &programName)
 Given the name of a binding, print a program call assuming that all options are specified. More...

 
template
<
typename
T
>
void SerializeIn (T *t, const std::string &str, const std::string &name)
 
template
<
typename
T
>
void SerializeInJSON (T *t, const std::string &str, const std::string &name)
 
template
<
typename
T
>
std::string SerializeOut (T *t, const std::string &name)
 
template
<
typename
T
>
std::string SerializeOutJSON (T *t, const std::string &name)
 
std::string SplitTrainTest (const std::string &datasetName, const std::string &labelName, const std::string &trainDataset, const std::string &trainLabels, const std::string &testDataset, const std::string &testLabels, const std::string &splitRatio)
 
void StripType (const std::string &inputType, std::string &strippedType, std::string &printedType, std::string &defaultsType)
 Given an input type like, e.g., "LogisticRegression<>", return three types that can be used in Python code. More...

 

Function Documentation

◆ CallMethod()

std::string mlpack::bindings::python::CallMethod ( const std::string &  bindingName,
const std::string &  objectName,
const std::string &  methodName,
Args...  args 
)

◆ CreateObject() [1/2]

std::string mlpack::bindings::python::CreateObject ( const std::string &  bindingName,
const std::string &  objectName,
const std::string &  groupName,
Args...  args 
)

◆ CreateObject() [2/2]

std::string mlpack::bindings::python::CreateObject ( const std::string &  bindingName,
const std::string &  objectName,
const std::string &  groupName 
)
inline

◆ DefaultParam()

void mlpack::bindings::python::DefaultParam ( util::ParamData data,
const void *  ,
void *  output 
)

Return the default value of an option.

This is the function that will be placed into the IO functionMap.

Definition at line 81 of file default_param.hpp.

◆ DefaultParamImpl() [1/5]

std::string mlpack::bindings::python::DefaultParamImpl ( util::ParamData data,
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 an option.

This is for regular types.

◆ DefaultParamImpl() [2/5]

std::string mlpack::bindings::python::DefaultParamImpl ( util::ParamData data,
const typename std::enable_if< util::IsStdVector< T >::value >::type *  = 0 
)

Return the default value of a vector option.

◆ DefaultParamImpl() [3/5]

std::string mlpack::bindings::python::DefaultParamImpl ( util::ParamData data,
const typename std::enable_if< std::is_same< T, std::string >::value >::type *  = 0 
)

Return the default value of a string option.

◆ DefaultParamImpl() [4/5]

std::string mlpack::bindings::python::DefaultParamImpl ( util::ParamData data,
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 
)

Return the default value of a matrix option, a tuple option, a serializable option, or a string option (this returns the default filename, or '' if the default is no file).

◆ DefaultParamImpl() [5/5]

std::string mlpack::bindings::python::DefaultParamImpl ( util::ParamData data,
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 a model option (this returns the default filename, or '' if the default is no file).

◆ GetArmaType()

std::string mlpack::bindings::python::GetArmaType ( )
inline

This is used for arma::Mat<> types; it will return "mat" for matrices, "row" for row vectors, and "col" for column vectors.

Definition at line 28 of file get_arma_type.hpp.

◆ GetBindingName()

std::string mlpack::bindings::python::GetBindingName ( const std::string &  bindingName)
inline

Given the name of a binding, print its Python name.

◆ GetClassName()

std::string mlpack::bindings::python::GetClassName ( const std::string &  groupName)
inline

◆ GetCythonType() [1/4]

std::string mlpack::bindings::python::GetCythonType ( util::ParamData ,
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 
)
inline

Definition at line 24 of file get_cython_type.hpp.

◆ GetCythonType() [2/4]

std::string mlpack::bindings::python::GetCythonType ( util::ParamData d,
const typename std::enable_if< util::IsStdVector< T >::value >::type *  = 0 
)
inline

Definition at line 87 of file get_cython_type.hpp.

◆ GetCythonType() [3/4]

std::string mlpack::bindings::python::GetCythonType ( util::ParamData d,
const typename std::enable_if< arma::is_arma_type< T >::value >::type *  = 0 
)
inline

Definition at line 95 of file get_cython_type.hpp.

◆ GetCythonType() [4/4]

std::string mlpack::bindings::python::GetCythonType ( util::ParamData d,
const typename std::enable_if<!arma::is_arma_type< T >::value >::type *  = 0,
const typename std::enable_if< data::HasSerialize< T >::value >::type *  = 0 
)
inline

Definition at line 109 of file get_cython_type.hpp.

References ParamData::cppType.

◆ GetCythonType< bool >()

std::string mlpack::bindings::python::GetCythonType< bool > ( util::ParamData ,
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 *   
)
inline

Definition at line 77 of file get_cython_type.hpp.

◆ GetCythonType< double >()

std::string mlpack::bindings::python::GetCythonType< double > ( util::ParamData ,
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 *   
)
inline

Definition at line 44 of file get_cython_type.hpp.

◆ GetCythonType< int >()

std::string mlpack::bindings::python::GetCythonType< int > ( util::ParamData ,
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 *   
)
inline

Definition at line 34 of file get_cython_type.hpp.

◆ GetCythonType< size_t >()

std::string mlpack::bindings::python::GetCythonType< size_t > ( util::ParamData ,
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 *   
)
inline

Definition at line 67 of file get_cython_type.hpp.

◆ GetCythonType< std::string >()

std::string mlpack::bindings::python::GetCythonType< std::string > ( util::ParamData ,
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 *   
)
inline

Definition at line 54 of file get_cython_type.hpp.

◆ GetDataset()

std::string mlpack::bindings::python::GetDataset ( const std::string &  datasetName,
const std::string &  url 
)
inline

◆ GetMappedName()

std::string mlpack::bindings::python::GetMappedName ( const std::string &  methodName)
inline

◆ GetMethods()

std::vector<std::string> mlpack::bindings::python::GetMethods ( const std::string &  validMethods)
inline

◆ GetNumpyType()

std::string mlpack::bindings::python::GetNumpyType ( )
inline

Definition at line 22 of file get_numpy_type.hpp.

◆ GetNumpyType< double >()

std::string mlpack::bindings::python::GetNumpyType< double > ( )
inline

Definition at line 28 of file get_numpy_type.hpp.

◆ GetNumpyType< size_t >()

std::string mlpack::bindings::python::GetNumpyType< size_t > ( )
inline

Definition at line 34 of file get_numpy_type.hpp.

◆ GetNumpyTypeChar()

std::string mlpack::bindings::python::GetNumpyTypeChar ( )
inline

Definition at line 23 of file get_numpy_type_char.hpp.

◆ GetNumpyTypeChar< arma::Col< size_t > >()

std::string mlpack::bindings::python::GetNumpyTypeChar< arma::Col< size_t > > ( )
inline

Definition at line 36 of file get_numpy_type_char.hpp.

◆ GetNumpyTypeChar< arma::mat >()

std::string mlpack::bindings::python::GetNumpyTypeChar< arma::mat > ( )
inline

Definition at line 49 of file get_numpy_type_char.hpp.

◆ GetNumpyTypeChar< arma::Mat< size_t > >()

std::string mlpack::bindings::python::GetNumpyTypeChar< arma::Mat< size_t > > ( )
inline

Definition at line 30 of file get_numpy_type_char.hpp.

◆ GetNumpyTypeChar< arma::Row< size_t > >()

std::string mlpack::bindings::python::GetNumpyTypeChar< arma::Row< size_t > > ( )
inline

Definition at line 42 of file get_numpy_type_char.hpp.

◆ GetNumpyTypeChar< arma::rowvec >()

std::string mlpack::bindings::python::GetNumpyTypeChar< arma::rowvec > ( )
inline

Definition at line 61 of file get_numpy_type_char.hpp.

◆ GetNumpyTypeChar< arma::vec >()

std::string mlpack::bindings::python::GetNumpyTypeChar< arma::vec > ( )
inline

Definition at line 55 of file get_numpy_type_char.hpp.

◆ GetParam()

void mlpack::bindings::python::GetParam ( util::ParamData d,
const void *  ,
void *  output 
)

All Python binding types are exactly what is held in the ParamData, so no special handling is necessary.

Definition at line 26 of file get_param.hpp.

References ParamData::value.

◆ GetPrintableParam() [1/6]

std::string mlpack::bindings::python::GetPrintableParam ( util::ParamData data,
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 an option of a simple type.

Print an option.

Definition at line 26 of file get_printable_param.hpp.

References ParamData::value.

◆ GetPrintableParam() [2/6]

std::string mlpack::bindings::python::GetPrintableParam ( util::ParamData data,
const typename std::enable_if< util::IsStdVector< T >::value >::type *  = 0 
)

Print a vector option, with spaces between it.

Definition at line 43 of file get_printable_param.hpp.

References ParamData::value.

◆ GetPrintableParam() [3/6]

std::string mlpack::bindings::python::GetPrintableParam ( util::ParamData data,
const typename std::enable_if< arma::is_arma_type< T >::value >::type *  = 0 
)

Print a matrix option (this prints its size).

Print a matrix option (this just prints the filename).

Definition at line 59 of file get_printable_param.hpp.

References ParamData::value.

◆ GetPrintableParam() [4/6]

std::string mlpack::bindings::python::GetPrintableParam ( util::ParamData data,
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 serializable class option (this prints the class name).

Print a serializable class option (this just prints the filename).

Print a model option (this just prints the filename).

Definition at line 75 of file get_printable_param.hpp.

References ParamData::cppType, and ParamData::value.

◆ GetPrintableParam() [5/6]

std::string mlpack::bindings::python::GetPrintableParam ( util::ParamData data,
const typename std::enable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>::value >::type *  = 0 
)

Print a combination DatasetInfo/matrix parameter.

Print a mapped matrix option (this just prints the filename).

Definition at line 89 of file get_printable_param.hpp.

References ParamData::value.

◆ GetPrintableParam() [6/6]

void mlpack::bindings::python::GetPrintableParam ( util::ParamData data,
const void *  ,
void *  output 
)

Print an option into a std::string.

This should print a short, one-line representation of the object. The string will be stored in the output pointer.

Parameters
dataParameter data struct.
*(input) Unused parameter.
outputOutput storage for the string.

Definition at line 114 of file get_printable_param.hpp.

◆ GetPrintableType() [1/6]

std::string mlpack::bindings::python::GetPrintableType ( util::ParamData ,
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 
)
inline

◆ GetPrintableType() [2/6]

std::string mlpack::bindings::python::GetPrintableType ( util::ParamData d,
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 
)
inline

◆ GetPrintableType() [3/6]

std::string mlpack::bindings::python::GetPrintableType ( util::ParamData ,
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 
)
inline

◆ GetPrintableType() [4/6]

std::string mlpack::bindings::python::GetPrintableType ( util::ParamData ,
const typename std::enable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>::value >::type *  = 0 
)
inline

◆ GetPrintableType() [5/6]

std::string mlpack::bindings::python::GetPrintableType ( util::ParamData d,
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 
)
inline

◆ GetPrintableType() [6/6]

void mlpack::bindings::python::GetPrintableType ( util::ParamData d,
const void *  ,
void *  output 
)

Definition at line 109 of file get_printable_type.hpp.

◆ GetPrintableType< bool >()

std::string mlpack::bindings::python::GetPrintableType< bool > ( util::ParamData ,
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 *   
)
inline

◆ GetPrintableType< double >()

std::string mlpack::bindings::python::GetPrintableType< double > ( util::ParamData ,
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 *   
)
inline

◆ GetPrintableType< int >()

std::string mlpack::bindings::python::GetPrintableType< int > ( util::ParamData ,
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 *   
)
inline

◆ GetPrintableType< size_t >()

std::string mlpack::bindings::python::GetPrintableType< size_t > ( util::ParamData ,
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 *   
)
inline

◆ GetPrintableType< std::string >()

std::string mlpack::bindings::python::GetPrintableType< std::string > ( util::ParamData ,
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 *   
)
inline

◆ GetValidName()

std::string mlpack::bindings::python::GetValidName ( const std::string &  paramName)
inline

Referenced by PrintDefn(), and PrintInputProcessing().

◆ IgnoreCheck() [1/3]

bool mlpack::bindings::python::IgnoreCheck ( const std::string &  bindingName,
const std::string &  paramName 
)
inline

Print whether or not we should ignore a check on the given parameter.

For Python bindings, we ignore any checks on output parameters, so if paramName is an output parameter, this returns true.

◆ IgnoreCheck() [2/3]

bool mlpack::bindings::python::IgnoreCheck ( const std::string &  bindingName,
const std::vector< std::string > &  constraints 
)
inline

Print whether or not we should ignore a check on the given set of constraints.

For Python bindings, we ignore any checks on output parameters, so if any parameter is an output parameter, this returns true.

◆ IgnoreCheck() [3/3]

bool mlpack::bindings::python::IgnoreCheck ( const std::string &  bindingName,
const std::vector< std::pair< std::string, bool >> &  constraints,
const std::string &  paramName 
)
inline

Print whether or not we should ignore a check on the given set of constraints.

For Python bindings, we ignore any checks on output parameters, so if any constraint parameter or the main parameter are output parameters, this returns true.

◆ ImportDecl() [1/4]

void mlpack::bindings::python::ImportDecl ( 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 
)

For a serializable type, print a cppclass definition.

This will give output of the form:

cdef cppclass Type: Type() nogil

Definition at line 26 of file import_decl.hpp.

References ParamData::cppType, and StripType().

◆ ImportDecl() [2/4]

void mlpack::bindings::python::ImportDecl ( util::ParamData ,
const size_t  ,
const typename std::enable_if<!arma::is_arma_type< T >::value >::type *  = 0,
const typename std::enable_if<!data::HasSerialize< T >::value >::type *  = 0 
)

For a non-serializable type, print nothing.

Definition at line 53 of file import_decl.hpp.

◆ ImportDecl() [3/4]

void mlpack::bindings::python::ImportDecl ( util::ParamData ,
const size_t  ,
const typename std::enable_if< arma::is_arma_type< T >::value >::type *  = 0 
)

For a matrix type, print nothing.

Definition at line 66 of file import_decl.hpp.

◆ ImportDecl() [4/4]

void mlpack::bindings::python::ImportDecl ( util::ParamData d,
const void *  indent,
void *   
)

Print the cppclass definition for a serializable model; print nothing for a non-serializable type.

Parameters
dParameter info struct.
indentPointer to size_t indicating indent.
*(output) Unused parameter.

Definition at line 83 of file import_decl.hpp.

◆ ImportExtLib()

std::string mlpack::bindings::python::ImportExtLib ( )
inline

◆ ImportSplit()

std::string mlpack::bindings::python::ImportSplit ( )
inline

◆ ImportThis()

std::string mlpack::bindings::python::ImportThis ( const std::string &  groupName)
inline

◆ IsSerializable() [1/3]

bool mlpack::bindings::python::IsSerializable ( util::ParamData ,
const typename boost::disable_if< data::HasSerialize< T >>::type *  = 0 
)
inline

Definition at line 22 of file is_serializable.hpp.

◆ IsSerializable() [2/3]

bool mlpack::bindings::python::IsSerializable ( util::ParamData ,
const typename boost::enable_if< data::HasSerialize< T >>::type *  = 0 
)
inline

Definition at line 30 of file is_serializable.hpp.

◆ IsSerializable() [3/3]

void mlpack::bindings::python::IsSerializable ( util::ParamData data,
const void *  ,
void *  output 
)

Definition at line 38 of file is_serializable.hpp.

◆ ParamString()

std::string mlpack::bindings::python::ParamString ( const std::string &  paramName)
inline

Given the parameter name, determine what it would actually be when passed to the command line.

◆ PrintClassDefn() [1/4]

void mlpack::bindings::python::PrintClassDefn ( util::ParamData ,
const typename std::enable_if<!arma::is_arma_type< T >::value >::type *  = 0,
const typename std::enable_if<!data::HasSerialize< T >::value >::type *  = 0 
)

Non-serializable models don't require any special definitions, so this prints nothing.

Definition at line 26 of file print_class_defn.hpp.

◆ PrintClassDefn() [2/4]

void mlpack::bindings::python::PrintClassDefn ( util::ParamData ,
const typename std::enable_if< arma::is_arma_type< T >::value >::type *  = 0 
)

Matrices don't require any special definitions, so this prints nothing.

Definition at line 38 of file print_class_defn.hpp.

◆ PrintClassDefn() [3/4]

void mlpack::bindings::python::PrintClassDefn ( util::ParamData d,
const typename std::enable_if<!arma::is_arma_type< T >::value >::type *  = 0,
const typename std::enable_if< data::HasSerialize< T >::value >::type *  = 0 
)

Serializable models require a special class definition.

This will produce code like:

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
def __getstate__(self):
return SerializeOut(self.modelptr, "<ModelType>")
def __setstate__(self, state):
SerializeIn(self.modelptr, state, "<ModelType>")
def __reduce_ex__(self):
return (self.__class__, (), self.__getstate__())
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)

Definition at line 49 of file print_class_defn.hpp.

References ParamData::cppType, and StripType().

◆ PrintClassDefn() [4/4]

void mlpack::bindings::python::PrintClassDefn ( util::ParamData d,
const void *  ,
void *   
)

Print the class definition to stdout.

Only serializable models require a different class definition, so anything else does nothing.

Parameters
dParameter data.
*(input) Unused parameter.
*(output) Unused parameter.

Definition at line 152 of file print_class_defn.hpp.

◆ PrintDataset()

std::string mlpack::bindings::python::PrintDataset ( const std::string &  datasetName)
inline

Given the name of a matrix, print it.

Here we do not need to modify anything.

◆ PrintDefault()

std::string mlpack::bindings::python::PrintDefault ( const std::string &  bindingName,
const std::string &  paramName 
)
inline

Given a parameter name, print its corresponding default value.

◆ PrintDefn()

void mlpack::bindings::python::PrintDefn ( util::ParamData d,
const void *  ,
void *   
)

Print the definition for a Python binding parameter to stdout.

This is the definition in the function declaration.

Definition at line 27 of file print_defn.hpp.

References GetValidName(), ParamData::name, and ParamData::required.

◆ PrintDoc()

void mlpack::bindings::python::PrintDoc ( util::ParamData d,
const void *  input,
void *   
)

Print the docstring documentation for a given parameter.

You are responsible for setting up the line—this does not handle indentation or anything. This is meant to produce a line of documentation describing a single parameter.

The indent parameter (void* input, which should be a pointer to a size_t) should be passed to know how much to indent for a new line.

Parameters
dParameter data struct.
inputPointer to size_t containing indent.
*(output) Unused parameter.

Definition at line 36 of file print_doc.hpp.

References ParamData::cppType, ParamData::desc, mlpack::util::HyphenateString(), if(), ParamData::name, and ParamData::required.

◆ PrintImport()

std::string mlpack::bindings::python::PrintImport ( const std::string &  bindingName)
inline

Print any import information for the Python binding.

◆ PrintInputOptionInfo()

std::string mlpack::bindings::python::PrintInputOptionInfo ( )
inline

Print any special information about input options.

◆ PrintInputOptions() [1/2]

std::string mlpack::bindings::python::PrintInputOptions ( util::Params params,
bool  onlyHyperParams,
bool  onlyMatrixParams 
)
inline

◆ PrintInputOptions() [2/2]

std::string mlpack::bindings::python::PrintInputOptions ( util::Params params,
bool  onlyHyperParams,
bool  onlyMatrixParams,
const std::string &  paramName,
const T &  value,
Args...  args 
)

Print an input option.

This will throw an exception if the parameter does not exist in IO. For a parameter 'x' with value '5', this will print something like x=5.

◆ PrintInputProcessing() [1/6]

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:

Detect if the parameter was passed; set if so.

if param_name is not None: if isinstance(param_name, int): SetParam[int](p, <const string> 'param_name', param_name) p.SetPassed(<const string> 'param_name') else: raise TypeError("'param_name' must have type 'list'!")

Definition at line 32 of file print_input_processing.hpp.

References GetValidName(), if(), ParamData::name, and ParamData::required.

◆ PrintInputProcessing() [2/6]

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]](p, <const string> 'param_name', param_name) p.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'!")

Definition at line 165 of file print_input_processing.hpp.

References GetValidName(), if(), ParamData::name, and ParamData::required.

◆ PrintInputProcessing() [3/6]

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:

Detect if the parameter was passed; set if so.

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](p, <const string> 'param_name', dereference(param_name_mat)) p.SetPassed(<const string> 'param_name')

Definition at line 255 of file print_input_processing.hpp.

References GetValidName(), ParamData::name, and ParamData::required.

◆ PrintInputProcessing() [4/6]

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:

Detect if the parameter was passed; set if so.

if param_name is not None: try: SetParamPtr[Model](p, 'param_name', (<ModelType?> param_name).modelptr, p.Has('copy_all_inputs')) except TypeError as e: if type(param_name).__name__ == "ModelType": SetParamPtr[Model](p, 'param_name', (<ModelType> param_name).modelptr, p.Has('copy_all_inputs')) else: raise e p.SetPassed(<const string>=""> 'param_name')

Definition at line 378 of file print_input_processing.hpp.

References ParamData::cppType, GetValidName(), ParamData::name, ParamData::required, and StripType().

◆ PrintInputProcessing() [5/6]

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](p, <const string> 'param_name', dereference(param_name_mat), &param_name_tuple[1][0]) p.SetPassed(<const string> 'param_name')

Definition at line 453 of file print_input_processing.hpp.

References GetValidName(), ParamData::name, and ParamData::required.

◆ PrintInputProcessing() [6/6]

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.

Parameters
dParameter data struct.
inputPointer to size_t holding the indentation.
*(output) Unused parameter.

Definition at line 535 of file print_input_processing.hpp.

◆ PrintModel()

std::string mlpack::bindings::python::PrintModel ( const std::string &  modelName)
inline

Given the name of a model, print it.

Here we do not need to modify anything.

◆ PrintOutputOptionInfo()

std::string mlpack::bindings::python::PrintOutputOptionInfo ( )
inline

Print any special information about output options.

◆ PrintOutputOptions() [1/2]

std::string mlpack::bindings::python::PrintOutputOptions ( util::Params params)
inline

◆ PrintOutputOptions() [2/2]

std::string mlpack::bindings::python::PrintOutputOptions ( util::Params params,
const std::string &  paramName,
const T &  value,
Args...  args 
)

◆ PrintOutputProcessing() [1/5]

void mlpack::bindings::python::PrintOutputProcessing ( util::Params ,
util::ParamData d,
const size_t  indent,
const bool  onlyOutput,
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 output processing for a regular parameter type.

This gives us code like:

result = p.Get[int]('param_name')

This gives us code like:

result['param_name'] = p.Get[int]('param_name')

Definition at line 29 of file print_output_processing.hpp.

References if(), and ParamData::name.

◆ PrintOutputProcessing() [2/5]

void mlpack::bindings::python::PrintOutputProcessing ( util::Params ,
util::ParamData d,
const size_t  indent,
const bool  onlyOutput,
const typename std::enable_if< arma::is_arma_type< T >::value >::type *  = 0 
)

Print output processing for a matrix type.

This gives us code like:

result = arma_numpy.mat_to_numpy_X(p.Get[mat]("name"))

where X indicates the type to convert to.

This gives us code like:

result['param_name'] = arma_numpy.mat_to_numpy_X(p.Get[mat]('name')

where X indicates the type to convert to.

Definition at line 86 of file print_output_processing.hpp.

References ParamData::name.

◆ PrintOutputProcessing() [3/5]

void mlpack::bindings::python::PrintOutputProcessing ( util::Params ,
util::ParamData d,
const size_t  indent,
const bool  onlyOutput,
const typename std::enable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>::value >::type *  = 0 
)

Print output processing for a dataset info / matrix combination.

This gives us code like:

result = arma_numpy.mat_to_numpy_X(GetParamWithInfo[mat](p, 'name'))

This gives us code like:

result['param_name'] = arma_numpy.mat_to_numpy_X(GetParamWithInfo[mat](p, 'name'))

Definition at line 129 of file print_output_processing.hpp.

References ParamData::name.

◆ PrintOutputProcessing() [4/5]

void mlpack::bindings::python::PrintOutputProcessing ( util::Params params,
util::ParamData d,
const size_t  indent,
const bool  onlyOutput,
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 output processing for a serializable model.

This gives us code like:

result = ModelType() (<ModelType?> result).modelptr = GetParamPtr[Model](p, 'name')

But we also have to check to ensure there aren't any input model parameters of the same type that could have the same model pointer. So we need to loop through all input parameters that have the same type, and double-check.

This gives us code like:

result['name'] = ModelType() (<ModelType?> result['name']).modelptr = GetParamPtr[Model](p, 'name'))

But we also have to check to ensure there aren't any input model parameters of the same type that could have the same model pointer. So we need to loop through all input parameters that have the same type, and double-check.

Definition at line 172 of file print_output_processing.hpp.

References ParamData::cppType, ParamData::input, ParamData::name, Params::Parameters(), ParamData::required, and StripType().

◆ PrintOutputProcessing() [5/5]

void mlpack::bindings::python::PrintOutputProcessing ( util::ParamData d,
const void *  input,
void *   
)

Given parameter information and the current number of spaces for indentation, print the code to process the output to cout.

This code assumes that data.input is false, and should not be called when data.input is true. If this is the only output, the results will be different.

The input pointer should be a pointer to a std::tuple<util::Params, std::tuple<size_t, bool>> where the first element is the parameters of the binding and the second element is a tuple where the first element is the indentation and the second element is a boolean representing whether or not this is the only output parameter.

Parameters
dParameter data struct.
inputPointer to size_t holding the indentation.
*(output) Unused parameter.

Definition at line 304 of file print_output_processing.hpp.

◆ PrintPYX()

void mlpack::bindings::python::PrintPYX ( const util::BindingDetails doc,
const std::string &  mainFilename,
const std::string &  functionName 
)

Given a list of parameter definition and program documentation, print a generated .pyx file to stdout.

Parameters
docDocumentation for the program.
mainFilenameFilename of the main program (i.e. "/path/to/pca_main.cpp").
functionNameName of the function (i.e. "pca").

◆ PrintTypeDoc() [1/6]

std::string mlpack::bindings::python::PrintTypeDoc ( util::ParamData data,
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 an option.

◆ PrintTypeDoc() [2/6]

std::string mlpack::bindings::python::PrintTypeDoc ( util::ParamData data,
const typename std::enable_if< util::IsStdVector< T >::value >::type *  = 0 
)

Return a string representing the command-line type of a vector.

◆ PrintTypeDoc() [3/6]

std::string mlpack::bindings::python::PrintTypeDoc ( util::ParamData data,
const typename std::enable_if< arma::is_arma_type< T >::value >::type *  = 0 
)

Return a string representing the command-line type of a matrix option.

◆ PrintTypeDoc() [4/6]

std::string mlpack::bindings::python::PrintTypeDoc ( util::ParamData data,
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 matrix tuple option.

◆ PrintTypeDoc() [5/6]

std::string mlpack::bindings::python::PrintTypeDoc ( util::ParamData data,
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 a string representing the command-line type of a model.

◆ PrintTypeDoc() [6/6]

void mlpack::bindings::python::PrintTypeDoc ( util::ParamData data,
const void *  ,
void *  output 
)

Print the command-line type of an option into a string.

Definition at line 72 of file print_type_doc.hpp.

◆ PrintValue() [1/2]

std::string mlpack::bindings::python::PrintValue ( const T &  value,
bool  quotes 
)
inline

Given a parameter type, print the corresponding value.

◆ PrintValue() [2/2]

std::string mlpack::bindings::python::PrintValue ( const bool &  value,
bool  quotes 
)
inline

◆ PrintWrapperPY()

void mlpack::bindings::python::PrintWrapperPY ( const std::string &  category,
const std::string &  groupName,
const std::string &  validMethods 
)

◆ ProgramCall() [1/2]

std::string mlpack::bindings::python::ProgramCall ( const std::string &  programName,
Args...  args 
)

Given a name of a binding and a variable number of arguments (and their contents), print the corresponding function call.

◆ ProgramCall() [2/2]

std::string mlpack::bindings::python::ProgramCall ( util::Params p,
const std::string &  programName 
)
inline

Given the name of a binding, print a program call assuming that all options are specified.

◆ SerializeIn()

void mlpack::bindings::python::SerializeIn ( T *  t,
const std::string &  str,
const std::string &  name 
)

Definition at line 34 of file serialization.hpp.

◆ SerializeInJSON()

void mlpack::bindings::python::SerializeInJSON ( T *  t,
const std::string &  str,
const std::string &  name 
)

Definition at line 54 of file serialization.hpp.

◆ SerializeOut()

std::string mlpack::bindings::python::SerializeOut ( T *  t,
const std::string &  name 
)

Definition at line 22 of file serialization.hpp.

◆ SerializeOutJSON()

std::string mlpack::bindings::python::SerializeOutJSON ( T *  t,
const std::string &  name 
)

Definition at line 42 of file serialization.hpp.

◆ SplitTrainTest()

std::string mlpack::bindings::python::SplitTrainTest ( const std::string &  datasetName,
const std::string &  labelName,
const std::string &  trainDataset,
const std::string &  trainLabels,
const std::string &  testDataset,
const std::string &  testLabels,
const std::string &  splitRatio 
)
inline

◆ StripType()

void mlpack::bindings::python::StripType ( const std::string &  inputType,
std::string &  strippedType,
std::string &  printedType,
std::string &  defaultsType 
)
inline

Given an input type like, e.g., "LogisticRegression<>", return three types that can be used in Python code.

strippedType will be a type with no template parameters (e.g. "LogisticRegression"), printedType will be a printable type with the template parameters (e.g. "LogisticRegression[]"), and defaultsType will be a printable type with a default template parameter (e.g. "LogisticRegression[T=*]") that can be used for class definitions.

Definition at line 28 of file strip_type.hpp.

Referenced by ImportDecl(), PrintClassDefn(), PrintInputProcessing(), and PrintOutputProcessing().