Skip to content

Commit

Permalink
Merge pull request #156 from tidymodels/hardh-check
Browse files Browse the repository at this point in the history
add hard R cmd check
  • Loading branch information
EmilHvitfeldt authored Oct 31, 2024
2 parents cc7c410 + db66b23 commit 575663c
Show file tree
Hide file tree
Showing 33 changed files with 186 additions and 108 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")'
2 changes: 1 addition & 1 deletion R/adasyn.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#' @family Steps for over-sampling
#'
#' @export
#' @examples
#' @examplesIf rlang::is_installed("modeldata")
#' library(recipes)
#' library(modeldata)
#' data(hpc_data)
Expand Down
2 changes: 1 addition & 1 deletion R/bsmote.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
#' @family Steps for over-sampling
#'
#' @export
#' @examples
#' @examplesIf rlang::is_installed("modeldata")
#' library(recipes)
#' library(modeldata)
#' data(hpc_data)
Expand Down
2 changes: 1 addition & 1 deletion R/downsample.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#' @family Steps for under-sampling
#'
#' @export
#' @examples
#' @examplesIf rlang::is_installed("modeldata")
#' library(recipes)
#' library(modeldata)
#' data(hpc_data)
Expand Down
2 changes: 1 addition & 1 deletion R/nearmiss.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#' @family Steps for under-sampling
#'
#' @export
#' @examples
#' @examplesIf rlang::is_installed("modeldata")
#' library(recipes)
#' library(modeldata)
#' data(hpc_data)
Expand Down
2 changes: 1 addition & 1 deletion R/rose.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
#' @family Steps for over-sampling
#'
#' @export
#' @examples
#' @examplesIf rlang::is_installed("modeldata")
#' library(recipes)
#' library(modeldata)
#' data(hpc_data)
Expand Down
2 changes: 1 addition & 1 deletion R/smote.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#' @family Steps for over-sampling
#'
#' @export
#' @examples
#' @examplesIf rlang::is_installed("modeldata")
#' library(recipes)
#' library(modeldata)
#' data(hpc_data)
Expand Down
2 changes: 1 addition & 1 deletion R/smotenc.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#' @family Steps for over-sampling
#'
#' @export
#' @examples
#' @examplesIf rlang::is_installed("modeldata")
#' library(recipes)
#' library(modeldata)
#' data(hpc_data)
Expand Down
2 changes: 1 addition & 1 deletion R/tomek.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#' @family Steps for under-sampling
#'
#' @export
#' @examples
#' @examplesIf rlang::is_installed("modeldata")
#' library(recipes)
#' library(modeldata)
#' data(hpc_data)
Expand Down
2 changes: 1 addition & 1 deletion R/upsample.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#' @family Steps for over-sampling
#'
#' @export
#' @examples
#' @examplesIf rlang::is_installed("modeldata")
#' library(recipes)
#' library(modeldata)
#' data(hpc_data)
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ library(recipes)
library(modeldata)
library(themis)
data("credit_data")
data("credit_data", package = "modeldata")
credit_data0 <- credit_data %>%
filter(!is.na(Job))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ library(recipes)
library(modeldata)
library(themis)

data("credit_data")
data("credit_data", package = "modeldata")

credit_data0 <- credit_data %>%
filter(!is.na(Job))
Expand Down
2 changes: 2 additions & 0 deletions man/step_adasyn.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/step_bsmote.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/step_downsample.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/step_nearmiss.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/step_rose.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/step_smote.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/step_smotenc.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/step_tomek.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/step_upsample.Rd

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

22 changes: 9 additions & 13 deletions tests/testthat/test-S3-methods.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
data(two_class_dat, package = "modeldata")

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

r1 <- recipe(Class ~ ., data = two_class_dat)
r2 <- r1 %>% step_adasyn(Class)
r3 <- r1 %>% step_bsmote(Class)
r4 <- r1 %>% step_downsample(Class)
r5 <- r1 %>% step_nearmiss(Class)
r6 <- r1 %>% step_rose(Class)
r7 <- r1 %>% step_smote(Class)
r8 <- r1 %>% step_tomek(Class)
r9 <- r1 %>% step_upsample(Class)
r1 <- recipe(class ~ ., data = circle_example)
r2 <- r1 %>% step_adasyn(class)
r3 <- r1 %>% step_bsmote(class)
r4 <- r1 %>% step_downsample(class)
r5 <- r1 %>% step_nearmiss(class)
r6 <- r1 %>% step_rose(class)
r7 <- r1 %>% step_smote(class)
r8 <- r1 %>% step_tomek(class)
r9 <- r1 %>% step_upsample(class)

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

Expand Down
21 changes: 12 additions & 9 deletions tests/testthat/test-adasyn.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
library(testthat)
library(recipes)
library(dplyr)
library(modeldata)

test_that("errors if there isn't enough data", {
data("credit_data")
skip_if_not_installed("modeldata")

data("credit_data", package = "modeldata")
credit_data0 <- credit_data

credit_data0$Status <- as.character(credit_data0$Status)
Expand Down Expand Up @@ -63,7 +60,9 @@ test_that("errors if character are present", {
})

test_that("NA in response", {
data(credit_data)
skip_if_not_installed("modeldata")

data("credit_data", package = "modeldata")

expect_snapshot(error = TRUE,
recipe(Job ~ Age, data = credit_data) %>%
Expand Down Expand Up @@ -128,7 +127,9 @@ test_that("ratio value works when oversampling", {
})

test_that("allows multi-class", {
data("credit_data")
skip_if_not_installed("modeldata")

data("credit_data", package = "modeldata")
expect_no_error(
recipe(Home ~ Age + Income + Assets, data = credit_data) %>%
step_impute_mean(Income, Assets) %>%
Expand All @@ -137,7 +138,9 @@ test_that("allows multi-class", {
})

test_that("majority classes are ignored if there is more than 1", {
data("penguins")
skip_if_not_installed("modeldata")

data("penguins", package = "modeldata")
rec1_p2 <- recipe(species ~ bill_length_mm + bill_depth_mm,
data = penguins[-(1:28), ]
) %>%
Expand Down
Loading

0 comments on commit 575663c

Please sign in to comment.