Skip to content

Commit 1db4a8b

Browse files
Merge pull request #1026 from tidymodels/fix-965
2 parents 4130a0b + 1aba5c1 commit 1db4a8b

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
* Fixed documentation for `mlp(engine = "brulee")`: the default values for `learn_rate` and `epochs` were swapped (#1018).
88

9+
* The `new_data` argument for the `predict()` method of `censoring_model_reverse_km()` has been deprecated (#965).
10+
911
* When computing censoring weights, the resulting vectors are no longer named (#1023).
1012

1113
# parsnip 1.1.1

R/survival-censoring-model.R

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,17 @@ predict.censoring_model <- function(object, ...) {
6161
}
6262

6363
#' @export
64-
predict.censoring_model_reverse_km <- function(object, new_data = NULL, time, as_vector = FALSE, ...) {
64+
predict.censoring_model_reverse_km <- function(object, new_data, time, as_vector = FALSE, ...) {
6565
rlang::check_installed("prodlim", version = "2022.10.13")
6666
rlang::check_installed("censored", version = "0.1.1.9002")
6767

68+
if (lifecycle::is_present(new_data)) {
69+
lifecycle::deprecate_stop(
70+
"1.2.0",
71+
"predict.censoring_model_reverse_km(new_data)"
72+
)
73+
}
74+
6875
res <- rep(NA_real_, length(time))
6976
if (length(time) == 0) {
7077
return(res)
@@ -76,13 +83,7 @@ predict.censoring_model_reverse_km <- function(object, new_data = NULL, time, as
7683
time <- time[-is_na]
7784
}
7885

79-
if (is.null(new_data)) {
80-
tmp <-
81-
purrr::map_dbl(time, ~ predict(object$fit, times = .x, type = "surv"))
82-
} else {
83-
tmp <-
84-
purrr::map_dbl(time, ~ predict(object$fit, newdata = new_data, times = .x, type = "surv"))
85-
}
86+
tmp <- purrr::map_dbl(time, ~ predict(object$fit, times = .x, type = "surv"))
8687

8788
zero_prob <- purrr::map_lgl(tmp, ~ !is.na(.x) && .x == 0)
8889
if (any(zero_prob)) {

0 commit comments

Comments
 (0)