Skip to content

Commit 26cc857

Browse files
Merge pull request #1435 from tidymodels/cleanup
2 parents 2f2f1a4 + 82ce33f commit 26cc857

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+104
-99
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ tests/testthat/NMF*
2121
^LICENSE\.md$
2222
^cran-comments\.md$
2323
^CRAN-SUBMISSION$
24+
^\.vscode$

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"[r]": {
3+
"editor.formatOnSave": true
4+
}
5+
}

NAMESPACE

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,6 @@ S3method(.get_data_types,logical)
1414
S3method(.get_data_types,numeric)
1515
S3method(.get_data_types,ordered)
1616
S3method(.get_data_types,textrecipes_tokenlist)
17-
S3method(.recipes_destroy_sparsity,default)
18-
S3method(.recipes_destroy_sparsity,step_arrange)
19-
S3method(.recipes_destroy_sparsity,step_filter)
20-
S3method(.recipes_destroy_sparsity,step_impute_mean)
21-
S3method(.recipes_destroy_sparsity,step_impute_median)
22-
S3method(.recipes_destroy_sparsity,step_rename)
23-
S3method(.recipes_destroy_sparsity,step_rename_at)
24-
S3method(.recipes_destroy_sparsity,step_sample)
25-
S3method(.recipes_destroy_sparsity,step_select)
26-
S3method(.recipes_destroy_sparsity,step_shuffle)
27-
S3method(.recipes_destroy_sparsity,step_slice)
28-
S3method(.recipes_destroy_sparsity,step_sqrt)
2917
S3method(.recipes_estimate_sparsity,default)
3018
S3method(.recipes_estimate_sparsity,recipe)
3119
S3method(.recipes_estimate_sparsity,step_count)
@@ -35,6 +23,18 @@ S3method(.recipes_estimate_sparsity,step_dummy_multi_choice)
3523
S3method(.recipes_estimate_sparsity,step_holiday)
3624
S3method(.recipes_estimate_sparsity,step_indicate_na)
3725
S3method(.recipes_estimate_sparsity,step_regex)
26+
S3method(.recipes_preserve_sparsity,default)
27+
S3method(.recipes_preserve_sparsity,step_arrange)
28+
S3method(.recipes_preserve_sparsity,step_filter)
29+
S3method(.recipes_preserve_sparsity,step_impute_mean)
30+
S3method(.recipes_preserve_sparsity,step_impute_median)
31+
S3method(.recipes_preserve_sparsity,step_rename)
32+
S3method(.recipes_preserve_sparsity,step_rename_at)
33+
S3method(.recipes_preserve_sparsity,step_sample)
34+
S3method(.recipes_preserve_sparsity,step_select)
35+
S3method(.recipes_preserve_sparsity,step_shuffle)
36+
S3method(.recipes_preserve_sparsity,step_slice)
37+
S3method(.recipes_preserve_sparsity,step_sqrt)
3838
S3method(bake,check_class)
3939
S3method(bake,check_cols)
4040
S3method(bake,check_missing)
@@ -542,8 +542,8 @@ S3method(tune_args,step)
542542
S3method(update,step)
543543
export("%>%")
544544
export(.get_data_types)
545-
export(.recipes_destroy_sparsity)
546545
export(.recipes_estimate_sparsity)
546+
export(.recipes_preserve_sparsity)
547547
export(.recipes_toggle_sparse_args)
548548
export(add_check)
549549
export(add_role)

R/BoxCox.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ prep.step_BoxCox <- function(x, training, info = NULL, ...) {
115115
limits = x$limits,
116116
num_unique = x$num_unique
117117
)
118-
if (any(is.na(values))) {
118+
if (anyNA(values)) {
119119
var_names <- names(values[is.na(values)])
120120
cli::cli_warn(
121121
"No Box-Cox transformation could be estimated for: {.var {var_names}}."

R/YeoJohnson.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ prep.step_YeoJohnson <- function(x, training, info = NULL, ...) {
118118
check_type(training[, col_names], types = c("double", "integer"))
119119
check_number_whole(x$num_unique, args = "num_unique")
120120
check_bool(x$na_rm, arg = "na_rm")
121-
if (!is.numeric(x$limits) || any(is.na(x$limits)) || length(x$limits) != 2) {
121+
if (!is.numeric(x$limits) || anyNA(x$limits) || length(x$limits) != 2) {
122122
cli::cli_abort(
123123
"{.arg limits} should be a numeric vector with two values,
124124
not {.obj_type_friendly {x$limits}}"

R/arrange.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,6 @@ tidy.step_arrange <- function(x, ...) {
144144
}
145145

146146
#' @export
147-
.recipes_destroy_sparsity.step_arrange <- function(x, ...) {
148-
FALSE
147+
.recipes_preserve_sparsity.step_arrange <- function(x, ...) {
148+
TRUE
149149
}

R/case_weights.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ averages <- function(x, wts = NULL, na_rm = TRUE) {
168168
res <- purrr::map_dbl(x, ~wt_calcs(.x, wts))
169169
}
170170
if (!na_rm) {
171-
res[map_lgl(x, ~any(is.na(.x)))] <- NA
171+
res[map_lgl(x, ~anyNA(.x))] <- NA
172172
}
173173
res
174174
}
@@ -211,7 +211,7 @@ variances <- function(x, wts = NULL, na_rm = TRUE) {
211211
wts <- as.double(wts)
212212
res <- purrr::map_dbl(x, ~wt_calcs(.x, wts, statistic = "var"))
213213
if (!na_rm) {
214-
res[map_lgl(x, ~any(is.na(.x)))] <- NA
214+
res[map_lgl(x, ~anyNA(.x))] <- NA
215215
}
216216
}
217217
res

R/corr.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ corr_filter <-
237237
)
238238
}
239239
}
240-
if (any(is.na(x))) {
240+
if (anyNA(x)) {
241241
cli::cli_warn(
242242
"The correlation matrix has sporadic missing values. \\
243243
Some columns were excluded from the filter."

R/cut.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ create_full_breaks <- function(var, breaks, call = rlang::caller_env()) {
155155
)
156156
}
157157

158-
if (any(is.na(var))) {
158+
if (anyNA(var)) {
159159
cli::cli_warn(
160160
"{.arg var} contains missing values. These will be ignored in break
161161
calculations.",

R/discretize.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ predict.discretize <- function(object, new_data, ...) {
185185
if (object$keep_na) {
186186
out_levels <- levels(out)
187187
out <- as.character(out)
188-
if (any(is.na(new_data))) {
188+
if (anyNA(new_data)) {
189189
missing_label <- object$labels[1] %||% "[missing]"
190190

191191
out[is.na(new_data)] <- missing_label

0 commit comments

Comments
 (0)