From ff8d1b8c3479ab6c10713e36df30c9d511502eaa Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Thu, 14 Dec 2023 12:02:26 -0800 Subject: [PATCH 1/2] undo parsnip dev dependency --- DESCRIPTION | 4 +++- R/recipe.R | 3 ++- tests/testthat/_snaps/basics.md | 8 ++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f1011edec..d53581ec5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -52,7 +52,7 @@ Suggests: kernlab, knitr, modeldata (>= 0.1.1), - parsnip (>= 0.1.7), + parsnip (>= 1.1.1.9001), RANN, RcppRoll, rmarkdown, @@ -72,3 +72,5 @@ Config/testthat/edition: 3 Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 +Remotes: + tidymodels/parsnip diff --git a/R/recipe.R b/R/recipe.R index 21a1e0350..893f3cc7e 100644 --- a/R/recipe.R +++ b/R/recipe.R @@ -282,7 +282,8 @@ inline_check <- function(x) { found: {.and {.code {funs}}}.", i = "Use steps to do transformations instead.", i = "If your modeling engine uses special terms in formulas, pass \\ - that formula to workflows as a model formula." + that formula to workflows as a \\ + {.help [model formula](parsnip::model_formula)}." )) } diff --git a/tests/testthat/_snaps/basics.md b/tests/testthat/_snaps/basics.md index dec999cef..9f7f9b2e1 100644 --- a/tests/testthat/_snaps/basics.md +++ b/tests/testthat/_snaps/basics.md @@ -7,7 +7,7 @@ x No in-line functions should be used here. i The following function was found: `log`. i Use steps to do transformations instead. - i If your modeling engine uses special terms in formulas, pass that formula to workflows as a model formula. + i If your modeling engine uses special terms in formulas, pass that formula to workflows as a model formula (`?parsnip::model_formula()`). --- @@ -18,7 +18,7 @@ x No in-line functions should be used here. i The following functions were found: `^` and `(`. i Use steps to do transformations instead. - i If your modeling engine uses special terms in formulas, pass that formula to workflows as a model formula. + i If your modeling engine uses special terms in formulas, pass that formula to workflows as a model formula (`?parsnip::model_formula()`). --- @@ -29,7 +29,7 @@ x No in-line functions should be used here. i The following function was found: `:`. i Use steps to do transformations instead. - i If your modeling engine uses special terms in formulas, pass that formula to workflows as a model formula. + i If your modeling engine uses special terms in formulas, pass that formula to workflows as a model formula (`?parsnip::model_formula()`). --- @@ -40,7 +40,7 @@ x No in-line functions should be used here. i The following function was found: `^`. i Use steps to do transformations instead. - i If your modeling engine uses special terms in formulas, pass that formula to workflows as a model formula. + i If your modeling engine uses special terms in formulas, pass that formula to workflows as a model formula (`?parsnip::model_formula()`). # Using prepare From 9960bbf27a32ed81f34a972671a027bbc64fb2af Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Thu, 14 Dec 2023 12:14:27 -0800 Subject: [PATCH 2/2] undo warn_new_levels() change --- R/dummy.R | 2 +- tests/testthat/_snaps/dummy.md | 12 ++++++------ tests/testthat/_snaps/unknown.md | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/R/dummy.R b/R/dummy.R index 4ce58cdb3..36b7938a2 100644 --- a/R/dummy.R +++ b/R/dummy.R @@ -224,7 +224,7 @@ warn_new_levels <- function(dat, lvl, details = NULL) { if (length(ind) > 0) { lvl2 <- unique(dat[ind]) cli::cli_warn(c( - "!" = "There are new levels in a factor: {lvl2}", + "!" = "There are new levels in a factor: {.var {lvl2}}.", details )) } diff --git a/tests/testthat/_snaps/dummy.md b/tests/testthat/_snaps/dummy.md index b089ac8b8..55f5d2bc5 100644 --- a/tests/testthat/_snaps/dummy.md +++ b/tests/testthat/_snaps/dummy.md @@ -25,7 +25,7 @@ factors <- prep(factors, training = sacr_missing) Condition Warning: - ! There are new levels in a factor: NA + ! There are new levels in a factor: `NA`. --- @@ -33,7 +33,7 @@ factors_data_1 <- bake(factors, new_data = sacr_missing) Condition Warning: - ! There are new levels in a factor: NA + ! There are new levels in a factor: `NA`. # tests for NA values in ordered factor @@ -41,7 +41,7 @@ factors <- prep(factors, training = sacr_ordered) Condition Warning: - ! There are new levels in a factor: NA + ! There are new levels in a factor: `NA`. --- @@ -49,7 +49,7 @@ factors_data_1 <- bake(factors, new_data = sacr_ordered) Condition Warning: - ! There are new levels in a factor: NA + ! There are new levels in a factor: `NA`. # new levels @@ -57,7 +57,7 @@ recipes:::warn_new_levels(testing$x1, levels(training$x1)) Condition Warning: - ! There are new levels in a factor: C + ! There are new levels in a factor: `C`. --- @@ -65,7 +65,7 @@ bake(rec, new_data = testing) Condition Warning: - ! There are new levels in a factor: C + ! There are new levels in a factor: `C`. Output # A tibble: 10 x 2 y x1_B diff --git a/tests/testthat/_snaps/unknown.md b/tests/testthat/_snaps/unknown.md index 53c79aa21..1e16efa32 100644 --- a/tests/testthat/_snaps/unknown.md +++ b/tests/testthat/_snaps/unknown.md @@ -4,11 +4,11 @@ te_1 <- bake(rec_1, sacr_te) Condition Warning: - ! There are new levels in a factor: WEST_SACRAMENTO + ! There are new levels in a factor: `WEST_SACRAMENTO`. * New levels will be coerced to `NA` by `step_unknown()`. i Consider using ?step_novel (`?recipes::step_novel()`) before `step_unknown()`. Warning: - ! There are new levels in a factor: z95691 + ! There are new levels in a factor: `z95691`. * New levels will be coerced to `NA` by `step_unknown()`. i Consider using ?step_novel (`?recipes::step_novel()`) before `step_unknown()`.