Skip to content

Rename predict(.time =) to predict(time =) #493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 18, 2021
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: parsnip
Version: 0.1.5.9002
Version: 0.1.5.9003
Title: A Common API to Modeling and Analysis Functions
Description: A common interface is provided to allow users to specify a model without having to remember the different argument names across different functions or computational engines (e.g. 'R', 'Spark', 'Stan', etc).
Authors@R: c(
Expand Down
18 changes: 9 additions & 9 deletions R/predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#' and "pred_int". Default value is `FALSE`.
#' \item `quantile`: the quantile(s) for quantile regression
#' (not implemented yet)
#' \item `.time`: the time(s) for hazard and survival probability estimates.
#' \item `time`: the time(s) for hazard and survival probability estimates.
#' }
#' @details If "type" is not supplied to `predict()`, then a choice
#' is made:
Expand All @@ -48,7 +48,7 @@
#'
#' ## Censored regression predictions
#'
#' For censored regression, a numeric vector for `.time` is required when
#' For censored regression, a numeric vector for `time` is required when
#' survival or hazard probabilities are requested. Also, when
#' `type = "linear_pred"`, censored regression models will be formatted such
#' that the linear predictor _increases_ with time. This may have the opposite
Expand Down Expand Up @@ -309,7 +309,7 @@ check_pred_type_dots <- function(type, ...) {

# ----------------------------------------------------------------------------

other_args <- c("level", "std_error", "quantile", ".time")
other_args <- c("level", "std_error", "quantile", "time")
is_pred_arg <- names(the_dots) %in% other_args
if (any(!is_pred_arg)) {
bad_args <- names(the_dots)[!is_pred_arg]
Expand All @@ -323,21 +323,21 @@ check_pred_type_dots <- function(type, ...) {
}

# ----------------------------------------------------------------------------
# places where .time should not be given
if (any(nms == ".time") & !type %in% c("survival", "hazard")) {
# places where time should not be given
if (any(nms == "time") & !type %in% c("survival", "hazard")) {
rlang::abort(
paste(
".time should only be passed to `predict()` when 'type' is one of:",
"'time' should only be passed to `predict()` when 'type' is one of:",
paste0("'", c("survival", "hazard"), "'", collapse = ", ")
)
)
}
# when .time should be passed
if (!any(nms == ".time") & type %in% c("survival", "hazard")) {
# when time should be passed
if (!any(nms == "time") & type %in% c("survival", "hazard")) {
rlang::abort(
paste(
"When using 'type' values of 'survival' or 'hazard' are given,",
"a numeric vector '.time' should also be given."
"a numeric vector 'time' should also be given."
)
)
}
Expand Down
4 changes: 2 additions & 2 deletions R/predict_hazard.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @export predict_hazard.model_fit
#' @export
predict_hazard.model_fit <-
function(object, new_data, .time, ...) {
function(object, new_data, time, ...) {

check_spec_pred_type(object, "hazard")

Expand All @@ -21,7 +21,7 @@ predict_hazard.model_fit <-
new_data <- object$spec$method$pred$hazard$pre(new_data, object)

# Pass some extra arguments to be used in post-processor
object$spec$method$pred$hazard$args$.time <- .time
object$spec$method$pred$hazard$args$time <- time
pred_call <- make_pred_call(object$spec$method$pred$hazard)

res <- eval_tidy(pred_call)
Expand Down
4 changes: 2 additions & 2 deletions R/predict_survival.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @export predict_survival.model_fit
#' @export
predict_survival.model_fit <-
function(object, new_data, .time, ...) {
function(object, new_data, time, ...) {

check_spec_pred_type(object, "survival")

Expand All @@ -21,7 +21,7 @@ predict_survival.model_fit <-
new_data <- object$spec$method$pred$survival$pre(new_data, object)

# Pass some extra arguments to be used in post-processor
object$spec$method$pred$survival$args$.time <- .time
object$spec$method$pred$survival$args$time <- time
pred_call <- make_pred_call(object$spec$method$pred$survival)

res <- eval_tidy(pred_call)
Expand Down
6 changes: 3 additions & 3 deletions man/other_predict.Rd

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

4 changes: 2 additions & 2 deletions man/predict.model_fit.Rd

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