Skip to content

Commit

Permalink
Merge pull request #518 from tidymodels/no-suggests
Browse files Browse the repository at this point in the history
Enable checks without suggested packages
  • Loading branch information
EmilHvitfeldt authored Oct 25, 2024
2 parents 87314bc + c859c50 commit f560b94
Show file tree
Hide file tree
Showing 46 changed files with 240 additions and 88 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/R-CMD-check-no-suggests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
#
# NOTE: This workflow only directly installs "hard" dependencies, i.e. Depends,
# Imports, and LinkingTo dependencies. Notably, Suggests dependencies are never
# installed, with the exception of testthat, knitr, and rmarkdown. The cache is
# never used to avoid accidentally restoring a cache containing a suggested
# dependency.
on:
push:
branches: [main, master]
pull_request:

name: R-CMD-check-no-suggests.yaml

permissions: read-all

jobs:
check-no-suggests:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'release'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
dependencies: '"hard"'
cache: false
extra-packages: |
any::rcmdcheck
any::testthat
any::knitr
any::rmarkdown
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
4 changes: 2 additions & 2 deletions R/conf_mat.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#' [summary.conf_mat()] for computing a large number of metrics from one
#' confusion matrix.
#'
#' @examples
#' @examplesIf rlang::is_installed(c("tidyr", "ggplot2"))
#' library(dplyr)
#' data("hpc_cv")
#'
Expand Down Expand Up @@ -342,7 +342,7 @@ flatten <- function(xtab, call = caller_env()) {
#'
#' [conf_mat()]
#'
#' @examples
#' @examplesIf rlang::is_installed(c("tidyr"))
#' data("two_class_example")
#'
#' cmat <- conf_mat(two_class_example, truth = "truth", estimate = "predicted")
Expand Down
2 changes: 1 addition & 1 deletion R/prob-gain_capture.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#'
#' @template examples-binary-prob
#' @template examples-multiclass-prob
#' @examples
#' @examplesIf rlang::is_installed(c("ggplot2"))
#' # ---------------------------------------------------------------------------
#' # Visualize gain_capture()
#'
Expand Down
2 changes: 1 addition & 1 deletion R/prob-gain_curve.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
#' @author Max Kuhn
#'
#' @template examples-binary-prob
#' @examples
#' @examplesIf rlang::is_installed(c("ggplot2"))
#' # ---------------------------------------------------------------------------
#' # `autoplot()`
#'
Expand Down
2 changes: 1 addition & 1 deletion R/prob-lift_curve.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#' @author Max Kuhn
#'
#' @template examples-binary-prob
#' @examples
#' @examplesIf rlang::is_installed(c("ggplot2"))
#' # ---------------------------------------------------------------------------
#' # `autoplot()`
#'
Expand Down
2 changes: 1 addition & 1 deletion R/prob-pr_curve.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#'
#' @author Max Kuhn
#' @template examples-binary-prob
#' @examples
#' @examplesIf rlang::is_installed(c("ggplot2"))
#' # ---------------------------------------------------------------------------
#' # `autoplot()`
#'
Expand Down
2 changes: 1 addition & 1 deletion R/prob-roc_curve.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#'
#' @author Max Kuhn
#' @template examples-binary-prob
#' @examples
#' @examplesIf rlang::is_installed(c("ggplot2"))
#' # ---------------------------------------------------------------------------
#' # `autoplot()`
#'
Expand Down
16 changes: 9 additions & 7 deletions R/surv-brier_survival.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
#'
#' @param ... The column identifier for the survival probabilities this
#' should be a list column of data.frames corresponding to the output given when
#' predicting with [censored](https://censored.tidymodels.org/) model. This
#' should be an unquoted column name although this argument is passed by
#' expression and supports [quasiquotation][rlang::quasiquotation] (you can
#' predicting with [censored](https://censored.tidymodels.org/) model. This
#' should be an unquoted column name although this argument is passed by
#' expression and supports [quasiquotation][rlang::quasiquotation] (you can
#' unquote column names). For `_vec()` functions, the dots are not used.
#'
#' @param estimate A list column of data.frames corresponding to the output
#' given when predicting with [censored](https://censored.tidymodels.org/)
#'
#' @param estimate A list column of data.frames corresponding to the output
#' given when predicting with [censored](https://censored.tidymodels.org/)
#' model. See the details for more information regarding format.
#'
#' @details
Expand Down Expand Up @@ -59,7 +59,9 @@
#' comparison of prognostic classification schemes for survival data,”
#' _Statistics in Medicine_, vol. 18, no. 17-18, pp. 2529–2545, 1999.
#'
#' @examples
#' @examplesIf rlang::is_installed(c("tidyr"))
#' # example code
#'
#' library(dplyr)
#'
#' lung_surv %>%
Expand Down
2 changes: 1 addition & 1 deletion R/surv-brier_survival_integrated.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#' and comparison of prognostic classification schemes for survival data,”
#' Statistics in Medicine, vol. 18, no. 17-18, pp. 2529–2545, 1999.
#'
#' @examples
#' @examplesIf rlang::is_installed(c("tidyr"))
#' library(dplyr)
#'
#' lung_surv %>%
Expand Down
2 changes: 1 addition & 1 deletion R/surv-roc_auc_survival.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#' and comparison of prognostic classification schemes for survival data.
#' _Statist. Med._, 18: 2529-2545.
#'
#' @examples
#' @examplesIf rlang::is_installed(c("tidyr"))
#' library(dplyr)
#'
#' lung_surv %>%
Expand Down
16 changes: 8 additions & 8 deletions R/surv-roc_curve_survival.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#' and comparison of prognostic classification schemes for survival data.
#' _Statist. Med._, 18: 2529-2545.
#'
#' @examples
#' @examplesIf rlang::is_installed(c("ggplot2"))
#' result <- roc_curve_survival(
#' lung_surv,
#' truth = surv_obj,
Expand Down Expand Up @@ -180,25 +180,25 @@ roc_curve_survival_impl <- function(truth,

roc_curve_survival_impl_one <- function(event_time, delta, data, case_weights) {
res <- dplyr::tibble(.threshold = sort(unique(c(-Inf, data$.pred_survival, Inf)), decreasing = TRUE))

obs_time_le_time <- event_time <= data$.eval_time
obs_time_gt_time <- event_time > data$.eval_time
n <- nrow(data)

sensitivity_denom <- sum(obs_time_le_time * delta * data$.weight_censored * case_weights, na.rm = TRUE)
specificity_denom <- sum(obs_time_gt_time * data$.weight_censored * case_weights, na.rm = TRUE)

data_df <- data.frame(
le_time = obs_time_le_time,
ge_time = obs_time_gt_time,
delta = delta,
weight_censored = data$.weight_censored,
case_weights = case_weights
)

data_split <- vec_split(data_df, data$.pred_survival)
data_split <- data_split$val[order(data_split$key)]

specificity <- vapply(
data_split,
function(x) sum(x$ge_time * x$weight_censored * x$case_weights, na.rm = TRUE),
Expand All @@ -217,14 +217,14 @@ roc_curve_survival_impl_one <- function(event_time, delta, data, case_weights) {
function(x) sum(x$le_time * x$delta * x$weight_censored * x$case_weights, na.rm = TRUE),
FUN.VALUE = numeric(1)
)

sensitivity <- cumsum(sensitivity)
sensitivity <- sensitivity / sensitivity_denom
sensitivity <- dplyr::if_else(sensitivity > 1, 1, sensitivity)
sensitivity <- dplyr::if_else(sensitivity < 0, 0, sensitivity)
sensitivity <- c(0, sensitivity, 1)
res$sensitivity <- sensitivity

res
}

Expand Down
4 changes: 4 additions & 0 deletions man/brier_survival.Rd

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

2 changes: 2 additions & 0 deletions man/brier_survival_integrated.Rd

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

10 changes: 5 additions & 5 deletions man/ccc.Rd

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

2 changes: 2 additions & 0 deletions man/conf_mat.Rd

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

3 changes: 2 additions & 1 deletion man/gain_capture.Rd

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

3 changes: 2 additions & 1 deletion man/gain_curve.Rd

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

2 changes: 1 addition & 1 deletion man/huber_loss.Rd

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

2 changes: 1 addition & 1 deletion man/huber_loss_pseudo.Rd

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

6 changes: 3 additions & 3 deletions man/iic.Rd

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

Loading

0 comments on commit f560b94

Please sign in to comment.