Skip to content

Commit

Permalink
Merge pull request #276 from tidymodels/rlang-type-checkers
Browse files Browse the repository at this point in the history
use rlang type checkers
  • Loading branch information
EmilHvitfeldt authored Nov 11, 2024
2 parents d52874a + f3b5443 commit a7700f0
Show file tree
Hide file tree
Showing 67 changed files with 1,868 additions and 47 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Imports:
magrittr,
Matrix,
purrr,
rlang,
rlang (>= 1.1.0),
SnowballC,
tibble,
tokenizers,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ importFrom(purrr,map_lgl)
importFrom(purrr,pmap)
importFrom(recipes,add_step)
importFrom(recipes,bake)
importFrom(recipes,check_name)
importFrom(recipes,check_new_data)
importFrom(recipes,check_type)
importFrom(recipes,get_keep_original_cols)
Expand Down
6 changes: 5 additions & 1 deletion R/dummy_hash.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ step_dummy_hash_new <-
prep.step_dummy_hash <- function(x, training, info = NULL, ...) {
col_names <- recipes_eval_select(x$terms, training, info)

check_bool(x$signed, arg = "signed")
check_number_whole(x$num_terms, min = 0, arg = "num_terms")
check_bool(x$collapse, arg = "collapse")

check_type(training[, col_names], types = c("string", "factor", "ordered"))

step_dummy_hash_new(
Expand Down Expand Up @@ -213,7 +217,7 @@ bake.step_dummy_hash <- function(object, new_data, ...) {
)

tf_text <- purrr::map_dfc(tf_text, as.integer)
tf_text <- check_name(tf_text, new_data, object, names(tf_text))
tf_text <- recipes::check_name(tf_text, new_data, object, names(tf_text))

new_data <- vec_cbind(new_data, tf_text)
}
Expand Down
Loading

0 comments on commit a7700f0

Please sign in to comment.