Skip to content

Commit 3c105ad

Browse files
Merge pull request #260 from tidymodels/update-snapshots
Update snapshots
2 parents a5188aa + 9225622 commit 3c105ad

18 files changed

+75
-71
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Suggests:
4242
janitor,
4343
knitr,
4444
modeldata,
45+
reticulate,
4546
rmarkdown,
4647
sentencepiece,
4748
spacyr,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Errors if vocabulary size is set to low.
2+
3+
Code
4+
recipe(~text1, data = test_data) %>% step_tokenize_bpe(text1, vocabulary_size = 10) %>%
5+
prep()
6+
Condition
7+
Error in `step_tokenize_bpe()`:
8+
Caused by error in `prep()`:
9+
! `vocabulary_size` of 10 is too small for column `text1` which has a unique character count of 23
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Errors if vocabulary size is set to low.
2+
3+
Code
4+
recipe(~text, data = tibble(text = "hello")) %>% step_tokenize(text, engine = "tokenizers.bpe",
5+
training_options = list(vocab_size = 2)) %>% prep()
6+
Condition
7+
Error in `step_tokenize()`:
8+
Caused by error in `prep()`:
9+
! `vocabulary_size` of 2 is too small for column `text` which has a unique character count of 4
10+

tests/testthat/_snaps/clean_names.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@
6464
Training data contained 20 data points and 4 incomplete rows.
6565
6666
-- Operations
67-
* Cleaning variable names for: Ozone, Solar.R, Wind, Temp, Month, Day | Trained
67+
* Cleaning variable names for: Ozone, Solar.R, Wind, Temp, ... | Trained
6868

tests/testthat/_snaps/dummy_hash.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
Condition
66
Error in `step_dummy_hash()`:
77
Caused by error in `bake()`:
8-
! Name collision occured. The following variable names already exists:
9-
i dummyhash_text_01
8+
! Name collision occurred. The following variable names already exist:
9+
* `dummyhash_text_01`
1010

1111
# empty printing
1212

@@ -49,8 +49,8 @@
4949
rec <- prep(rec)
5050
Condition
5151
Warning:
52-
'keep_original_cols' was added to `step_dummy_hash()` after this recipe was created.
53-
Regenerate your recipe to avoid this warning.
52+
`keep_original_cols` was added to `step_dummy_hash()` after this recipe was created.
53+
i Regenerate your recipe to avoid this warning.
5454

5555
# printing
5656

tests/testthat/_snaps/lda.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
Condition
66
Error in `step_lda()`:
77
Caused by error in `bake()`:
8-
! Name collision occured. The following variable names already exists:
9-
i lda_text_1
8+
! Name collision occurred. The following variable names already exist:
9+
* `lda_text_1`
1010

1111
# empty printing
1212

@@ -49,8 +49,8 @@
4949
rec <- prep(rec)
5050
Condition
5151
Warning:
52-
'keep_original_cols' was added to `step_lda()` after this recipe was created.
53-
Regenerate your recipe to avoid this warning.
52+
`keep_original_cols` was added to `step_lda()` after this recipe was created.
53+
i Regenerate your recipe to avoid this warning.
5454

5555
# printing
5656

tests/testthat/_snaps/sequence_onehot.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
Condition
3939
Error in `step_sequence_onehot()`:
4040
Caused by error in `bake()`:
41-
! Name collision occured. The following variable names already exists:
42-
i seq1hot_text_1
41+
! Name collision occurred. The following variable names already exist:
42+
* `seq1hot_text_1`
4343

4444
# empty printing
4545

@@ -82,8 +82,8 @@
8282
rec <- prep(rec)
8383
Condition
8484
Warning:
85-
'keep_original_cols' was added to `step_sequence_onehot()` after this recipe was created.
86-
Regenerate your recipe to avoid this warning.
85+
`keep_original_cols` was added to `step_sequence_onehot()` after this recipe was created.
86+
i Regenerate your recipe to avoid this warning.
8787

8888
# printing
8989

tests/testthat/_snaps/textfeature.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
Condition
2727
Error in `step_textfeature()`:
2828
Caused by error in `bake()`:
29-
! Name collision occured. The following variable names already exists:
30-
i textfeature_text_n_words
29+
! Name collision occurred. The following variable names already exist:
30+
* `textfeature_text_n_words`
3131

3232
# empty printing
3333

@@ -70,17 +70,17 @@
7070
rec <- prep(rec)
7171
Condition
7272
Warning:
73-
'keep_original_cols' was added to `step_tf()` after this recipe was created.
74-
Regenerate your recipe to avoid this warning.
73+
`keep_original_cols` was added to `step_tf()` after this recipe was created.
74+
i Regenerate your recipe to avoid this warning.
7575

7676
---
7777

7878
Code
7979
rec <- prep(rec)
8080
Condition
8181
Warning:
82-
'keep_original_cols' was added to `step_textfeature()` after this recipe was created.
83-
Regenerate your recipe to avoid this warning.
82+
`keep_original_cols` was added to `step_textfeature()` after this recipe was created.
83+
i Regenerate your recipe to avoid this warning.
8484

8585
# printing
8686

tests/testthat/_snaps/texthash.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
Condition
66
Error in `step_texthash()`:
77
Caused by error in `bake()`:
8-
! Name collision occured. The following variable names already exists:
9-
i texthash_text_0001
8+
! Name collision occurred. The following variable names already exist:
9+
* `texthash_text_0001`
1010

1111
# empty printing
1212

@@ -49,8 +49,8 @@
4949
rec <- prep(rec)
5050
Condition
5151
Warning:
52-
'keep_original_cols' was added to `step_texthash()` after this recipe was created.
53-
Regenerate your recipe to avoid this warning.
52+
`keep_original_cols` was added to `step_texthash()` after this recipe was created.
53+
i Regenerate your recipe to avoid this warning.
5454

5555
# printing
5656

tests/testthat/_snaps/tf.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
Condition
66
Error in `step_tf()`:
77
Caused by error in `bake()`:
8-
! Name collision occured. The following variable names already exists:
9-
i tf_text_i
8+
! Name collision occurred. The following variable names already exist:
9+
* `tf_text_i`
1010

1111
# empty printing
1212

@@ -49,8 +49,8 @@
4949
rec <- prep(rec)
5050
Condition
5151
Warning:
52-
'keep_original_cols' was added to `step_tf()` after this recipe was created.
53-
Regenerate your recipe to avoid this warning.
52+
`keep_original_cols` was added to `step_tf()` after this recipe was created.
53+
i Regenerate your recipe to avoid this warning.
5454

5555
# printing
5656

tests/testthat/_snaps/tfidf.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
Condition
66
Error in `step_tfidf()`:
77
Caused by error in `bake()`:
8-
! Name collision occured. The following variable names already exists:
9-
i tfidf_text_i
8+
! Name collision occurred. The following variable names already exist:
9+
* `tfidf_text_i`
1010

1111
# Backwards compatibility with 1592690d36581fc5f4952da3e9b02351b31f1a2e
1212

@@ -69,8 +69,8 @@
6969
rec <- prep(rec)
7070
Condition
7171
Warning:
72-
'keep_original_cols' was added to `step_tfidf()` after this recipe was created.
73-
Regenerate your recipe to avoid this warning.
72+
`keep_original_cols` was added to `step_tfidf()` after this recipe was created.
73+
i Regenerate your recipe to avoid this warning.
7474

7575
# printing
7676

tests/testthat/_snaps/tokenize_bpe.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
# Errors if vocabulary size is set to low.
2-
3-
Code
4-
recipe(~text1, data = test_data) %>% step_tokenize_bpe(text1, vocabulary_size = 10) %>%
5-
prep()
6-
Condition
7-
Error in `step_tokenize_bpe()`:
8-
Caused by error in `prep()`:
9-
! `vocabulary_size` of 10 is too small for column `text1` which has a unique character count of 23
10-
111
# empty printing
122

133
Code

tests/testthat/_snaps/tokenizer-tokenizersbpe.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,3 @@
1414
Error:
1515
! Invalid index: field name 'pos' not found
1616

17-
# Errors if vocabulary size is set to low.
18-
19-
Code
20-
recipe(~text, data = tibble(text = "hello")) %>% step_tokenize(text, engine = "tokenizers.bpe",
21-
training_options = list(vocab_size = 2)) %>% prep()
22-
Condition
23-
Error in `step_tokenize()`:
24-
Caused by error in `prep()`:
25-
! `vocabulary_size` of 2 is too small for column `text` which has a unique character count of 4
26-

tests/testthat/_snaps/tokenmerge.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
Condition
66
Error in `step_tokenmerge()`:
77
Caused by error in `prep()`:
8-
! All columns selected for the step should be tokenlist.
8+
x All columns selected for the step should be tokenlist.
9+
* 2 factor variables found: `text1` and `text2`
910

1011
# check_name() is used
1112

@@ -14,8 +15,8 @@
1415
Condition
1516
Error in `step_tokenmerge()`:
1617
Caused by error in `bake()`:
17-
! Name collision occured. The following variable names already exists:
18-
i tokenmerge
18+
! Name collision occurred. The following variable names already exist:
19+
* `tokenmerge`
1920

2021
# empty printing
2122

@@ -58,8 +59,8 @@
5859
rec <- prep(rec)
5960
Condition
6061
Warning:
61-
'keep_original_cols' was added to `step_tokenmerge()` after this recipe was created.
62-
Regenerate your recipe to avoid this warning.
62+
`keep_original_cols` was added to `step_tokenmerge()` after this recipe was created.
63+
i Regenerate your recipe to avoid this warning.
6364

6465
# printing
6566

@@ -74,8 +75,8 @@
7475
predictor: 2
7576
7677
-- Operations
77-
* Tokenization for: text1, text2
78-
* Merging tokens for: text1, text2
78+
* Tokenization for: text1 and text2
79+
* Merging tokens for: text1 and text2
7980

8081
---
8182

@@ -93,6 +94,6 @@
9394
Training data contained 4 data points and no incomplete rows.
9495
9596
-- Operations
96-
* Tokenization for: text1, text2 | Trained
97-
* Merging tokens for: text1, text2 | Trained
97+
* Tokenization for: text1 and text2 | Trained
98+
* Merging tokens for: text1 and text2 | Trained
9899

tests/testthat/_snaps/word_embeddings.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
Condition
66
Error in `step_word_embeddings()`:
77
Caused by error in `bake()`:
8-
! Name collision occured. The following variable names already exists:
9-
i wordembed_text_d1
8+
! Name collision occurred. The following variable names already exist:
9+
* `wordembed_text_d1`
1010

1111
# empty printing
1212

@@ -49,8 +49,8 @@
4949
rec <- prep(rec)
5050
Condition
5151
Warning:
52-
'keep_original_cols' was added to `step_word_embeddings()` after this recipe was created.
53-
Regenerate your recipe to avoid this warning.
52+
`keep_original_cols` was added to `step_word_embeddings()` after this recipe was created.
53+
i Regenerate your recipe to avoid this warning.
5454

5555
# printing
5656

tests/testthat/helper-functions.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
skip_if_no_python_or_no_spacy <- function() {
2-
if (spacyr::find_spacy_env()) {
2+
if (reticulate::py_module_available("spacy")) {
33
return(NULL)
4-
}
5-
spacy_path <- spacyr::find_spacy(ask = FALSE)
6-
if (is.null(spacy_path)) {
4+
} else {
75
testthat::skip("Skip the test as spaCy is not found")
8-
} else if (is.na(spacy_path)) {
9-
testthat::skip("Skip the test as python is not found")
106
}
117
}

tests/testthat/test-tokenize_bpe.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
library(textrecipes)
22
library(recipes)
33

4+
r_version <- function() paste0("R", getRversion()[, 1:2])
5+
46
text1 <- c(
57
"I would not eat them here or there.",
68
"I would not eat them anywhere.",
@@ -122,7 +124,8 @@ test_that("arguments are passed to tokenizers.bpe", {
122124

123125
test_that("Errors if vocabulary size is set to low.", {
124126
expect_snapshot(
125-
error = TRUE,
127+
error = TRUE,
128+
variant = r_version(),
126129
recipe(~text1, data = test_data) %>%
127130
step_tokenize_bpe(text1, vocabulary_size = 10) %>%
128131
prep()

tests/testthat/test-tokenizer-tokenizersbpe.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
library(textrecipes)
22
library(recipes)
33

4+
r_version <- function() paste0("R", getRversion()[, 1:2])
5+
46
text1 <- c(
57
"I would not eat them here or there.",
68
"I would not eat them anywhere.",
@@ -154,6 +156,7 @@ test_that("arguments are passed to tokenizers.bpe", {
154156
test_that("Errors if vocabulary size is set to low.", {
155157
expect_snapshot(
156158
error = TRUE,
159+
variant = r_version(),
157160
recipe(~text, data = tibble(text = "hello")) %>%
158161
step_tokenize(text,
159162
engine = "tokenizers.bpe",

0 commit comments

Comments
 (0)