Skip to content

Commit

Permalink
updates for no-suggests checks (#160)
Browse files Browse the repository at this point in the history
* add new GHA

* add skip

* update vignette

* protections for inline code

* many skips

* more test updates

* SKIP

* update docs

* another example

* more examples
  • Loading branch information
topepo authored Oct 16, 2024
1 parent 545f9ab commit 369cef3
Show file tree
Hide file tree
Showing 18 changed files with 185 additions and 29 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/R-CMD-check-hard.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-hard.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")'
8 changes: 5 additions & 3 deletions R/cal-estimate-beta.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
#' \url{https://www.tidymodels.org/learn/models/calibration/},
#' [cal_validate_beta()]
#' @examples
#' # It will automatically identify the probability columns
#' # if passed a model fitted with tidymodels
#' cal_estimate_beta(segment_logistic, Class)
#' if (rlang::is_installed("betacal")) {
#' # It will automatically identify the probability columns
#' # if passed a model fitted with tidymodels
#' cal_estimate_beta(segment_logistic, Class)
#' }
#' @export
cal_estimate_beta <- function(.data,
truth = NULL,
Expand Down
9 changes: 5 additions & 4 deletions R/cal-validate.R
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,11 @@ cal_validate_isotonic_boot.tune_results <- function(.data,
#'
#' library(dplyr)
#'
#' segment_logistic %>%
#' rsample::vfold_cv() %>%
#' cal_validate_beta(Class)
#'
#' if (rlang::is_installed("betacal")) {
#' segment_logistic %>%
#' rsample::vfold_cv() %>%
#' cal_validate_beta(Class)
#' }
#' @export
cal_validate_beta <- function(.data,
truth = NULL,
Expand Down
2 changes: 1 addition & 1 deletion R/conformal_infer_cv.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#' Rina Foygel Barber, Emmanuel J. Candès, Aaditya Ramdas, Ryan J. Tibshirani
#' "Predictive inference with the jackknife+," _The Annals of Statistics_,
#' 49(1), 486-507, 2021
#' @examplesIf !probably:::is_cran_check()
#' @examplesIf !probably:::is_cran_check() & rlang::is_installed(c("modeldata", "parsnip"))
#' library(workflows)
#' library(dplyr)
#' library(parsnip)
Expand Down
2 changes: 1 addition & 1 deletion R/conformal_infer_quantile.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#' @references
#' Romano, Yaniv, Evan Patterson, and Emmanuel Candes. "Conformalized quantile
#' regression." _Advances in neural information processing systems_ 32 (2019).
#' @examplesIf !probably:::is_cran_check()
#' @examplesIf !probably:::is_cran_check() & rlang::is_installed(c("modeldata", "parsnip", "quantregForest"))
#' library(workflows)
#' library(dplyr)
#' library(parsnip)
Expand Down
2 changes: 1 addition & 1 deletion R/conformal_infer_split.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#' @references
#' Lei, Jing, et al. "Distribution-free predictive inference for regression."
#' _Journal of the American Statistical Association_ 113.523 (2018): 1094-1111.
#' @examplesIf !probably:::is_cran_check()
#' @examplesIf !probably:::is_cran_check() & rlang::is_installed(c("modeldata", "parsnip", "nnet"))
#' library(workflows)
#' library(dplyr)
#' library(parsnip)
Expand Down
8 changes: 5 additions & 3 deletions man/cal_estimate_beta.Rd

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

9 changes: 5 additions & 4 deletions man/cal_validate_beta.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/int_conformal_cv.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/int_conformal_quantile.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/int_conformal_split.Rd

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

6 changes: 3 additions & 3 deletions tests/testthat/_snaps/cal-estimate.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
Type: Regression
Source class: Data Frame
Data points: 2,000
Unique Predicted Values: 43
Unique Predicted Values: 40
Truth variable: `outcome`
Estimate variables:
`.pred` ==> predictions
Expand All @@ -229,7 +229,7 @@
Type: Regression
Source class: Data Frame
Data points: 2,000, split in 10 groups
Unique Predicted Values: 11
Unique Predicted Values: 16
Truth variable: `outcome`
Estimate variables:
`.pred` ==> predictions
Expand Down Expand Up @@ -373,7 +373,7 @@
---

Code
print(mtnl_isotonic)
print(mtnl_beta)
Message
-- Probability Calibration
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/test-cal-apply.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ test_that("Logistic apply works - data.frame", {
})

test_that("Logistic apply works - tune_results", {
skip_if_not_installed("modeldata")

tct <- testthat_cal_binary()
tl_logistic <- cal_estimate_logistic(tct, smooth = FALSE)
tap_logistic <- cal_apply(tct, tl_logistic)
Expand All @@ -27,6 +29,8 @@ test_that("Logistic spline apply works", {
})

test_that("Logistic spline apply works - tune_results", {
skip_if_not_installed("modeldata")

tct <- testthat_cal_binary()
tl_gam <- cal_estimate_logistic(tct)
tap_gam <- cal_apply(tct, tl_gam)
Expand Down Expand Up @@ -90,6 +94,8 @@ test_that("Isotonic apply works - data.frame", {
})

test_that("Isotonic apply works - tune_results", {
skip_if_not_installed("modeldata")

tct <- testthat_cal_binary()
tl_isotonic <- cal_estimate_isotonic(tct)
tap_isotonic <- cal_apply(tct, tl_isotonic)
Expand All @@ -107,6 +113,8 @@ test_that("Isotonic Bootstrapped apply works - data.frame", {
})

test_that("Isotonic Bootstrapped apply works - tune_results", {
skip_if_not_installed("modeldata")

tct <- testthat_cal_binary()
tl_boot <- cal_estimate_isotonic_boot(tct)
tap_boot <- cal_apply(tct, tl_boot)
Expand All @@ -119,6 +127,7 @@ test_that("Isotonic Bootstrapped apply works - tune_results", {
# ------------------------------------------------------------------------------

test_that("Beta apply works - data.frame", {
skip_if_not_installed("betacal")
sl_beta <- cal_estimate_beta(segment_logistic, Class)
ap_beta <- cal_apply(segment_logistic, sl_beta)

Expand All @@ -128,6 +137,9 @@ test_that("Beta apply works - data.frame", {
})

test_that("Beta apply works - tune_results", {
skip_if_not_installed("betacal")
skip_if_not_installed("modeldata")

tct <- testthat_cal_binary()
tl_beta <- cal_estimate_beta(tct)
tap_beta <- cal_apply(tct, tl_beta)
Expand All @@ -148,12 +160,16 @@ test_that("Passing the data frame first returns expected abort message", {
})

test_that("Passing a tune_results without saved predictions causes error", {
skip_if_not_installed("betacal")
skip_if_not_installed("modeldata")

tct <- testthat_cal_binary()
tl_beta <- cal_estimate_beta(tct)
expect_error(cal_apply(tune::ames_grid_search, tl_beta))
})

test_that("Passing a calibration object as the first arg fails", {
skip_if_not_installed("betacal")
sl_beta <- cal_estimate_beta(segment_logistic, Class)
expect_error(cal_apply(sl_beta, segment_logistic))
})
Loading

0 comments on commit 369cef3

Please sign in to comment.