Skip to content

Commit c9edff9

Browse files
committed
air whole package
1 parent 8fb63d4 commit c9edff9

Some content is hidden

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

55 files changed

+855
-555
lines changed

R/aaa.R

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,47 @@
33

44
utils::globalVariables(
55
c(
6-
".", "..object", ".cluster", ".iter_config", ".iter_model",
7-
".iter_preprocessor", ".msg_model", ".submodels", "call_info", "cluster",
8-
"component", "component_id", "compute_intercept", "data", "dist", "engine",
9-
"engine2", "exposed", "func", "id", "iteration", "lab", "name", "neighbor",
10-
"new_data", "object", "orig_label", "original", "predictor_indicators",
11-
"remove_intercept", "seed", "sil_width", "splits", "tunable", "type",
12-
"value", "x", "y"
6+
".",
7+
"..object",
8+
".cluster",
9+
".iter_config",
10+
".iter_model",
11+
".iter_preprocessor",
12+
".msg_model",
13+
".submodels",
14+
"call_info",
15+
"cluster",
16+
"component",
17+
"component_id",
18+
"compute_intercept",
19+
"data",
20+
"dist",
21+
"engine",
22+
"engine2",
23+
"exposed",
24+
"func",
25+
"id",
26+
"iteration",
27+
"lab",
28+
"name",
29+
"neighbor",
30+
"new_data",
31+
"object",
32+
"orig_label",
33+
"original",
34+
"predictor_indicators",
35+
"remove_intercept",
36+
"seed",
37+
"sil_width",
38+
"splits",
39+
"tunable",
40+
"type",
41+
"value",
42+
"x",
43+
"y"
1344
)
1445
)
1546

16-
1747
release_bullets <- function() {
1848
c(
1949
"Run `knit_engine_docs()` and `devtools::document()` to update docs"

R/append.R

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# https://github.com/tidymodels/tune/blob/main/R/pull.R#L136
2-
append_predictions <- function(collection,
3-
predictions,
4-
split,
5-
control,
6-
.config = NULL) {
2+
append_predictions <- function(
3+
collection,
4+
predictions,
5+
split,
6+
control,
7+
.config = NULL
8+
) {
79
if (!control$save_pred) {
810
return(NULL)
911
}
@@ -27,14 +29,16 @@ append_predictions <- function(collection,
2729
dplyr::bind_rows(collection, predictions)
2830
}
2931

30-
append_metrics <- function(workflow,
31-
collection,
32-
predictions,
33-
metrics,
34-
param_names,
35-
event_level,
36-
split,
37-
.config = NULL) {
32+
append_metrics <- function(
33+
workflow,
34+
collection,
35+
predictions,
36+
metrics,
37+
param_names,
38+
event_level,
39+
split,
40+
.config = NULL
41+
) {
3842
if (inherits(predictions, "try-error")) {
3943
return(collection)
4044
}
@@ -54,20 +58,22 @@ append_metrics <- function(workflow,
5458
dplyr::bind_rows(collection, tmp_est)
5559
}
5660

57-
append_extracts <- function(collection,
58-
workflow,
59-
grid,
60-
split,
61-
ctrl,
62-
.config = NULL) {
61+
append_extracts <- function(
62+
collection,
63+
workflow,
64+
grid,
65+
split,
66+
ctrl,
67+
.config = NULL
68+
) {
6369
extracts <-
6470
grid %>%
65-
dplyr::bind_cols(labels(split)) %>%
66-
dplyr::mutate(
67-
.extracts = list(
68-
extract_details(workflow, ctrl$extract)
71+
dplyr::bind_cols(labels(split)) %>%
72+
dplyr::mutate(
73+
.extracts = list(
74+
extract_details(workflow, ctrl$extract)
75+
)
6976
)
70-
)
7177

7278
if (!rlang::is_null(.config)) {
7379
extracts <- cbind(extracts, .config)

R/arguments.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ check_eng_args <- function(args, obj, core_args) {
88
if (length(common_args) > 0) {
99
args <- args[!(names(args) %in% common_args)]
1010
common_args <- paste0(common_args, collapse = ", ")
11-
rlang::warn(glue::glue(
12-
"The following arguments cannot be manually modified ",
13-
"and were removed: {common_args}."
14-
))
11+
rlang::warn(
12+
glue::glue(
13+
"The following arguments cannot be manually modified ",
14+
"and were removed: {common_args}."
15+
)
16+
)
1517
}
1618
args
1719
}
@@ -25,7 +27,8 @@ make_x_call <- function(object, target) {
2527
}
2628

2729
object$method$fit$args[[unname(data_args["x"])]] <-
28-
switch(target,
30+
switch(
31+
target,
2932
none = rlang::expr(x),
3033
data.frame = rlang::expr(maybe_data_frame(x)),
3134
matrix = rlang::expr(maybe_matrix(x)),

R/cluster_spec.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@
1111
#' @keywords internal
1212
new_cluster_spec <- function(cls, args, eng_args, mode, method, engine) {
1313
modelenv::check_spec_mode_engine_val(
14-
model = cls,
14+
model = cls,
1515
mode = mode,
1616
eng = engine,
1717
call = rlang::caller_env()
1818
)
1919

2020
out <- list(
21-
args = args, eng_args = eng_args,
22-
mode = mode, method = method, engine = engine
21+
args = args,
22+
eng_args = eng_args,
23+
mode = mode,
24+
method = method,
25+
engine = engine
2326
)
2427
class(out) <- make_classes_tidyclust(cls)
2528
out <- modelenv::new_unsupervised_spec(out)

R/compat-purrr.R

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,16 @@ imap <- function(.x, .f, ...) {
7979
pmap <- function(.l, .f, ...) {
8080
.f <- as.function(.f)
8181
args <- .rlang_purrr_args_recycle(.l)
82-
do.call("mapply", c(
83-
FUN = list(quote(.f)),
84-
args, MoreArgs = quote(list(...)),
85-
SIMPLIFY = FALSE, USE.NAMES = FALSE
86-
))
82+
do.call(
83+
"mapply",
84+
c(
85+
FUN = list(quote(.f)),
86+
args,
87+
MoreArgs = quote(list(...)),
88+
SIMPLIFY = FALSE,
89+
USE.NAMES = FALSE
90+
)
91+
)
8792
}
8893
.rlang_purrr_args_recycle <- function(args) {
8994
lengths <- map_int(args, length)

R/convert_data.R

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@
3232
#' @inheritParams fit.cluster_spec
3333
#' @rdname convert_helpers
3434
#' @keywords internal
35-
.convert_form_to_x_fit <- function(formula,
36-
data,
37-
...,
38-
na.action = na.omit,
39-
indicators = "traditional",
40-
composition = "data.frame",
41-
remove_intercept = TRUE) {
35+
.convert_form_to_x_fit <- function(
36+
formula,
37+
data,
38+
...,
39+
na.action = na.omit,
40+
indicators = "traditional",
41+
composition = "data.frame",
42+
remove_intercept = TRUE
43+
) {
4244
if (!(composition %in% c("data.frame", "matrix"))) {
4345
rlang::abort("`composition` should be either 'data.frame' or 'matrix'.")
4446
}
@@ -155,9 +157,7 @@ local_one_hot_contrasts <- function(frame = rlang::caller_env()) {
155157
#' @inheritParams .convert_form_to_x_fit
156158
#' @rdname convert_helpers
157159
#' @keywords internal
158-
.convert_x_to_form_fit <- function(x,
159-
weights = NULL,
160-
remove_intercept = TRUE) {
160+
.convert_x_to_form_fit <- function(x, weights = NULL, remove_intercept = TRUE) {
161161
if (is.vector(x)) {
162162
rlang::abort("`x` cannot be a vector.")
163163
}
@@ -212,10 +212,12 @@ make_formula <- function(x, short = TRUE) {
212212
#' @inheritParams predict.cluster_fit
213213
#' @rdname convert_helpers
214214
#' @keywords internal
215-
.convert_form_to_x_new <- function(object,
216-
new_data,
217-
na.action = stats::na.pass,
218-
composition = "data.frame") {
215+
.convert_form_to_x_new <- function(
216+
object,
217+
new_data,
218+
na.action = stats::na.pass,
219+
composition = "data.frame"
220+
) {
219221
if (!(composition %in% c("data.frame", "matrix"))) {
220222
rlang::abort("`composition` should be either 'data.frame' or 'matrix'.")
221223
}

R/dials-params.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ linkage_method <- function(values = values_linkage_method) {
4040
#' @rdname linkage_method
4141
#' @export
4242
values_linkage_method <- c(
43-
"ward.D", "ward.D2", "single", "complete", "average", "mcquitty", "median",
43+
"ward.D",
44+
"ward.D2",
45+
"single",
46+
"complete",
47+
"average",
48+
"mcquitty",
49+
"median",
4450
"centroid"
4551
)

R/engine_docs.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ knit_engine_docs <- function(pattern = NULL) {
1919
}
2020
outputs <- gsub("Rmd$", "md", files)
2121

22-
res <- map2(files, outputs, ~ try(knitr::knit(.x, .y), silent = TRUE))
23-
is_error <- map_lgl(res, ~ inherits(.x, "try-error"))
22+
res <- map2(files, outputs, ~try(knitr::knit(.x, .y), silent = TRUE))
23+
is_error <- map_lgl(res, ~inherits(.x, "try-error"))
2424

2525
if (any(is_error)) {
2626
# In some cases where there are issues, the md file is empty.
2727
errors <- res[which(is_error)]
2828
error_nms <- basename(files)[which(is_error)]
2929
errors <-
30-
map_chr(errors, ~ cli::ansi_strip(as.character(.x))) %>%
31-
map2_chr(error_nms, ~ paste0(.y, ": ", .x)) %>%
32-
map_chr(~ gsub("Error in .f(.x[[i]], ...) :", "", .x, fixed = TRUE))
30+
map_chr(errors, ~cli::ansi_strip(as.character(.x))) %>%
31+
map2_chr(error_nms, ~paste0(.y, ": ", .x)) %>%
32+
map_chr(~gsub("Error in .f(.x[[i]], ...) :", "", .x, fixed = TRUE))
3333
cat("There were failures duing knitting:\n\n")
3434
cat(errors)
3535
cat("\n\n")

R/engines.R

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ set_engine.cluster_spec <- function(object, engine, ...) {
3131
stop_missing_engine <- function(cls, call = rlang::caller_env()) {
3232
info <-
3333
modelenv::get_from_env(cls) %>%
34-
dplyr::group_by(mode) %>%
35-
dplyr::summarize(
36-
msg = paste0(
37-
unique(mode), " {",
38-
paste0(unique(engine), collapse = ", "),
39-
"}"
40-
),
41-
.groups = "drop"
42-
)
34+
dplyr::group_by(mode) %>%
35+
dplyr::summarize(
36+
msg = paste0(
37+
unique(mode),
38+
" {",
39+
paste0(unique(engine), collapse = ", "),
40+
"}"
41+
),
42+
.groups = "drop"
43+
)
4344
if (nrow(info) == 0) {
4445
rlang::abort(glue::glue("No known engines for `{cls}()`."), call = call)
4546
}

R/extract_cluster_assignment.R

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,11 @@ extract_cluster_assignment.kmodes <- function(object, ...) {
111111
}
112112

113113
#' @export
114-
extract_cluster_assignment.hclust <- function(object,
115-
...,
116-
call = rlang::caller_env(0)) {
114+
extract_cluster_assignment.hclust <- function(
115+
object,
116+
...,
117+
call = rlang::caller_env(0)
118+
) {
117119
# if k or h is passed in the dots, use those. Otherwise, use attributes
118120
# from original model specification
119121
args <- list(...)
@@ -159,10 +161,12 @@ extract_cluster_assignment.hclust <- function(object,
159161

160162
# ------------------------------------------------------------------------------
161163

162-
cluster_assignment_tibble <- function(clusters,
163-
n_clusters,
164-
...,
165-
prefix = "Cluster_") {
164+
cluster_assignment_tibble <- function(
165+
clusters,
166+
n_clusters,
167+
...,
168+
prefix = "Cluster_"
169+
) {
166170
reorder_clusts <- order(union(unique(clusters), seq_len(n_clusters)))
167171
names <- paste0(prefix, seq_len(n_clusters))
168172
res <- names[reorder_clusts][clusters]

0 commit comments

Comments
 (0)