Skip to content

Commit

Permalink
error for predict when used on model_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt committed Feb 2, 2019
1 parent 399169c commit 758776b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ S3method(predict,"_elnet")
S3method(predict,"_lognet")
S3method(predict,"_multnet")
S3method(predict,model_fit)
S3method(predict,model_spec)
S3method(predict_class,"_lognet")
S3method(predict_class,model_fit)
S3method(predict_classprob,"_lognet")
Expand Down
7 changes: 5 additions & 2 deletions R/predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
predict.model_fit <- function (object, new_data, type = NULL, opts = list(), ...) {
if (any(names(enquos(...)) == "newdata"))
stop("Did you mean to use `new_data` instead of `newdata`?", call. = FALSE)

type <- check_pred_type(object, type)
if (type != "raw" && length(opts) > 0)
warning("`opts` is only used with `type = 'raw'` and was ignored.")
Expand Down Expand Up @@ -224,4 +224,7 @@ multi_predict.default <- function(object, ...)
stop ("No `multi_predict` method exists for objects with classes ",
paste0("'", class(), "'", collapse = ", "), call. = FALSE)


#' @export
predict.model_spec <- function(object, ...) {
stop("You must use `fit` on your model specification before you can use `predict`.", call. = FALSE)
}

0 comments on commit 758776b

Please sign in to comment.