Skip to content

Commit

Permalink
escalate deprecation of options arg to step_nzv()
Browse files Browse the repository at this point in the history
  • Loading branch information
hfrick committed Sep 17, 2021
1 parent 6224e00 commit ff7c2b2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Expand Up @@ -31,6 +31,8 @@

* The deprecation of the `preserve` argument to `step_pls()` and `step_dummy()` was escalated from a soft deprecation to regular deprecation.

* The deprecation of the `options` argument to `step_nzv()` was escalated to a deprecation error.


# recipes 0.1.16

Expand Down
10 changes: 4 additions & 6 deletions R/nzv.R
Expand Up @@ -82,15 +82,13 @@ step_nzv <-
if (!isTRUE(all.equal(exp_list, options))) {
freq_cut <- options$freq_cut
unique_cut <- options$unique_cut
message(
paste(
"The argument `options` is deprecated in favor of `freq_cut`",
"and `unique_cut`. options` will be removed in next version."
)
lifecycle::deprecate_stop(
"0.1.7",
"step_nzv(options)",
details = "Please use the arguments `freq_cut` and `unique_cut` instead."
)
}


add_step(
recipe,
step_nzv_new(
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/_snaps/nzv.md
@@ -0,0 +1,5 @@
# altered freq_cut and unique_cut

The `options` argument of `step_nzv()` was deprecated in recipes 0.1.7 and is now defunct.
Please use the arguments `freq_cut` and `unique_cut` instead.

12 changes: 7 additions & 5 deletions tests/testthat/test_nzv.R
Expand Up @@ -42,15 +42,17 @@ test_that('nzv filtering', {
expect_equal(filtering_trained$steps[[1]]$removals, removed)
})

test_that('altered options', {
test_that('altered freq_cut and unique_cut', {
rec <- recipe(y ~ ., data = dat)

expect_message(
filtering <- rec %>%
step_nzv(x1, x2, x3, x4, options = list(freq_cut = 50, unique_cut = 10)),
"deprecated in favor of"
expect_snapshot_error(
rec %>%
step_nzv(x1, x2, x3, x4, options = list(freq_cut = 50, unique_cut = 10))
)

filtering <- rec %>%
step_nzv(x1, x2, x3, x4, freq_cut = 50, unique_cut = 10)

filtering_trained <- prep(filtering, training = dat, verbose = FALSE)

removed <- vars[
Expand Down

0 comments on commit ff7c2b2

Please sign in to comment.