Use global option for verbosity in R package and add tests.
This commit is contained in:
@@ -335,3 +335,25 @@ test_that("TestReallyNotVerbose", {
|
||||
build_model=TRUE,
|
||||
verbose=FALSE))
|
||||
})
|
||||
|
||||
# Make sure that the mlpack verbose global option does anything at all.
|
||||
test_that("TestGlobalVerbose", {
|
||||
options(mlpack.verbose = TRUE)
|
||||
expect_output(test_r_binding(4.0, 12, "hello",
|
||||
build_model=TRUE))
|
||||
})
|
||||
|
||||
# Test that we get no output when the global verbose option is set to false.
|
||||
test_that("TestGlobalNotVerbose", {
|
||||
options(mlpack.verbose = FALSE)
|
||||
expect_silent(test_r_binding(4.0, 12, "hello",
|
||||
build_model=TRUE))
|
||||
})
|
||||
|
||||
# Test that we can override the global verbose option.
|
||||
test_that("TestGlobalVerboseOverride", {
|
||||
options(mlpack.verbose = TRUE)
|
||||
expect_silent(test_r_binding(4.0, 12, "hello",
|
||||
build_model=TRUE,
|
||||
verbose=FALSE))
|
||||
})
|
||||
|
||||
@@ -30,9 +30,22 @@ void PrintInputParam(util::ParamData& d,
|
||||
{
|
||||
MLPACK_COUT_STREAM << d.name;
|
||||
if (std::is_same<T, bool>::value)
|
||||
MLPACK_COUT_STREAM << "=FALSE";
|
||||
{
|
||||
if (d.name == "verbose")
|
||||
{
|
||||
// Make sure that we use the global verbose option for the mlpack package
|
||||
// as the default.
|
||||
MLPACK_COUT_STREAM << "=getOption(\"mlpack.verbose\", FALSE)";
|
||||
}
|
||||
else
|
||||
{
|
||||
MLPACK_COUT_STREAM << "=FALSE";
|
||||
}
|
||||
}
|
||||
else if (!d.required)
|
||||
{
|
||||
MLPACK_COUT_STREAM << "=NA";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace r
|
||||
|
||||
Reference in New Issue
Block a user