Skip to content

Commit

Permalink
Merge pull request tidymodels#1277 from tidymodels/get-back-to-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt committed Dec 14, 2023
2 parents 7fd3e90 + 9960bbf commit 36a1307
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Suggests:
kernlab,
knitr,
modeldata (>= 0.1.1),
parsnip (>= 0.1.7),
parsnip (>= 1.1.1.9001),
RANN,
RcppRoll,
rmarkdown,
Expand All @@ -72,3 +72,5 @@ Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Remotes:
tidymodels/parsnip
2 changes: 1 addition & 1 deletion R/dummy.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
))
}
Expand Down
3 changes: 2 additions & 1 deletion R/recipe.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)}."
))
}

Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/_snaps/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`).

---

Expand All @@ -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()`).

---

Expand All @@ -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()`).

---

Expand All @@ -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

Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/_snaps/dummy.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,47 @@
factors <- prep(factors, training = sacr_missing)
Condition
Warning:
! There are new levels in a factor: NA
! There are new levels in a factor: `NA`.

---

Code
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

Code
factors <- prep(factors, training = sacr_ordered)
Condition
Warning:
! There are new levels in a factor: NA
! There are new levels in a factor: `NA`.

---

Code
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

Code
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`.

---

Code
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
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/unknown.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.

Expand Down

0 comments on commit 36a1307

Please sign in to comment.