Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ S3method(predict_raw,"_multnet")
S3method(predict_raw,model_fit)
S3method(print,boost_tree)
S3method(print,decision_tree)
S3method(print,fit_control)
S3method(print,linear_reg)
S3method(print,logistic_reg)
S3method(print,mars)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
of possible varying arguments is returned (as opposed to only the arguments
that are actually varying).

* `fit_control()` not returns an S3 method.

## Bug Fixes

* `varying_args()` now uses the version from the `generics` package. This means
Expand Down
22 changes: 17 additions & 5 deletions R/fit_control.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' Control the fit function
#'
#' Options can be passed to the [fit()] function that control the output and
#'
#' Options can be passed to the [fit()] function that control the output and
#' computations
#'
#'
#' @param verbosity An integer where a value of zero indicates
#' that no messages or output should be shown when packages are
#' loaded or when the model is fit. A value of 1 means that package
Expand All @@ -14,12 +14,24 @@
#' the model inside of `try(, silent = TRUE)`. If the model fails,
#' an object is still returned (without an error) that inherits the
#' class "try-error".
#' @return A named list with the results of the function call
#' @return An S3 object with class "fit_control" that is a named list with the
#' results of the function call
#' @export
#'
#'

fit_control <- function(verbosity = 1L, catch = FALSE) {
res <- list(verbosity = verbosity, catch = catch)
res <- check_control(res)
class(res) <- "fit_control"
res
}

#' @export
print.fit_control <- function(x, ...) {
cat("parsnip control object\n")
if (x$verbosity > 1)
cat(" - verbose level", x$verbosity, "\n")
if (x$catch)
cat(" - fit errors will be caught\n")
invisible(x)
}
3 changes: 2 additions & 1 deletion man/fit_control.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.