Skip to content

Commit

Permalink
add skip_on_cran() for lda and texthash
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt committed Aug 17, 2023
1 parent 50194fb commit 7526469
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/testthat/test-lda.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ rec <- recipe(~ medium + artist, data = tate_text[seq_len(n_rows), ])

test_that("step_lda works as intended", {
skip_if_not_installed("text2vec")
skip_on_cran() # because data.table uses all cores by default

n_top <- 10
rec1 <- rec %>%
step_tokenize(medium) %>%
Expand All @@ -25,6 +27,8 @@ test_that("step_lda works as intended", {

test_that("step_lda works with num_topics argument", {
skip_if_not_installed("text2vec")
skip_on_cran() # because data.table uses all cores by default

n_top <- 100
rec1 <- rec %>%
step_tokenize(medium) %>%
Expand All @@ -38,6 +42,8 @@ test_that("step_lda works with num_topics argument", {

test_that("check_name() is used", {
skip_if_not_installed("text2vec")
skip_on_cran() # because data.table uses all cores by default

dat <- tate_text[seq_len(100), ]
dat$text <- dat$medium
dat$lda_text_1 <- dat$text
Expand All @@ -56,6 +62,8 @@ test_that("check_name() is used", {

test_that("bake method errors when needed non-standard role columns are missing", {
skip_if_not_installed("text2vec")
skip_on_cran() # because data.table uses all cores by default

tokenized_test_data <- rec %>%
step_tokenize(medium) %>%
prep() %>%
Expand Down Expand Up @@ -118,6 +126,7 @@ test_that("empty selection tidy method works", {

test_that("keep_original_cols works", {
skip_if_not_installed("text2vec")
skip_on_cran() # because data.table uses all cores by default

new_names <- paste0("lda_medium_", 1:10)

Expand Down Expand Up @@ -148,6 +157,7 @@ test_that("keep_original_cols works", {

test_that("keep_original_cols - can prep recipes with it missing", {
skip_if_not_installed("text2vec")
skip_on_cran() # because data.table uses all cores by default

rec <- recipe(~ medium, data = tate_text[seq_len(n_rows), ]) %>%
step_tokenize(medium) %>%
Expand All @@ -168,6 +178,8 @@ test_that("keep_original_cols - can prep recipes with it missing", {

test_that("printing", {
skip_if_not_installed("text2vec")
skip_on_cran() # because data.table uses all cores by default

rec <- rec %>%
step_tokenize(medium) %>%
step_lda(medium)
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-texthash.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ rec <- recipe(~., data = test_data)

test_that("hashing gives double outputs", {
skip_if_not_installed("text2vec")
skip_on_cran() # because data.table uses all cores by default

rec <- rec %>%
step_tokenize(text) %>%
step_texthash(text)
Expand All @@ -33,6 +35,8 @@ test_that("hashing gives double outputs", {

test_that("hashing output width changes accordingly with num_terms", {
skip_if_not_installed("text2vec")
skip_on_cran() # because data.table uses all cores by default

rec <- rec %>%
step_tokenize(text) %>%
step_texthash(text, num_terms = 256) %>%
Expand All @@ -48,6 +52,7 @@ test_that("hashing output width changes accordingly with num_terms", {

test_that("hashing output width changes accordingly with num_terms", {
skip_if_not_installed("text2vec")
skip_on_cran() # because data.table uses all cores by default

signed <- recipe(~., data = test_data) %>%
step_tokenize(all_predictors()) %>%
Expand All @@ -68,6 +73,9 @@ test_that("hashing output width changes accordingly with num_terms", {
})

test_that("check_name() is used", {
skip_if_not_installed("text2vec")
skip_on_cran() # because data.table uses all cores by default

dat <- test_data
dat$texthash_text_0001 <- dat$text

Expand Down Expand Up @@ -161,6 +169,9 @@ test_that("empty selection tidy method works", {
})

test_that("keep_original_cols works", {
skip_if_not_installed("text2vec")
skip_on_cran() # because data.table uses all cores by default

new_names <- paste0("texthash_text_", 1:5)

rec <- recipe(~text, data = test_data) %>%
Expand Down Expand Up @@ -207,6 +218,8 @@ test_that("keep_original_cols - can prep recipes with it missing", {

test_that("printing", {
skip_if_not_installed("text2vec")
skip_on_cran() # because data.table uses all cores by default

rec <- rec %>%
step_tokenize(text) %>%
step_texthash(text)
Expand Down

0 comments on commit 7526469

Please sign in to comment.