Skip to content

Commit

Permalink
Merge pull request #281 from tidyverse/f-styler
Browse files Browse the repository at this point in the history
chore: Apply styler
  • Loading branch information
krlmlr authored Oct 19, 2024
2 parents 2e1be7a + ec3d49e commit a618f03
Show file tree
Hide file tree
Showing 70 changed files with 131 additions and 135 deletions.
2 changes: 1 addition & 1 deletion R/add_count.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
add_count.duckplyr_df <- function(x, ..., wt = NULL, sort = FALSE, name = NULL, .drop = deprecated()) {
# Our implementation
rel_try(
rel_try(NULL,
"No relational implementation for add_count()" = TRUE,
{
return(out)
Expand Down
3 changes: 2 additions & 1 deletion R/anti_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ anti_join.duckplyr_df <- function(x, y, by = NULL, copy = FALSE, ..., na_matches
na_matches <- check_na_matches(na_matches, error_call = error_call)

# Our implementation
rel_try(call = list(name = "anti_join", x = x, y = y, args = list(by = if(!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, na_matches = na_matches)),
rel_try(list(name = "anti_join", x = x, y = y, args = list(by = if (!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, na_matches = na_matches)),
"No restrictions" = FALSE,
{
out <- rel_join_impl(x, y, by, "anti", na_matches, error_call = error_call)
return(out)
Expand Down
8 changes: 4 additions & 4 deletions R/arrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ arrange.duckplyr_df <- function(.data, ..., .by_group = FALSE, .locale = NULL) {
dots <- enquos(...)
dots <- unname(dots)

rel_try(call = list(name = "arrange", x = .data, args = list(dots = dots, .by_group = .by_group)),
rel_try(list(name = "arrange", x = .data, args = list(dots = dots, .by_group = .by_group)),
".by_group = TRUE not supported" = !identical(.by_group, FALSE),
".locale argument not supported" = !is.null(.locale),
"dplyr.legacy_locale not supported" = isTRUE(getOption("dplyr.legacy_locale")),
Expand All @@ -17,9 +17,9 @@ arrange.duckplyr_df <- function(.data, ..., .by_group = FALSE, .locale = NULL) {
return(.data)
}

dots_ascending <- handle_desc(dots)
dots <- dots_ascending$dots
ascending <- dots_ascending$ascending
dots_ascending <- handle_desc(dots)
dots <- dots_ascending$dots
ascending <- dots_ascending$ascending

exprs <- rel_translate_dots(dots, .data)

Expand Down
2 changes: 1 addition & 1 deletion R/compute.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
compute.duckplyr_df <- function(x, ...) {
# Our implementation
rel_try(
rel_try(NULL,
"No relational implementation for compute()" = TRUE,
{
return(out)
Expand Down
4 changes: 3 additions & 1 deletion R/construct_constant.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ opts_relational_relexpr_constant <- function(constructor = c("relexpr_constant",

.cstr_construct.relational_relexpr_constant <- function(x, ...) {
opts <- list(...)$opts$relational_relexpr_constant %||% opts_relational_relexpr_constant()
if (is_corrupted_relational_relexpr_constant(x) || opts$constructor == "next") return(NextMethod())
if (is_corrupted_relational_relexpr_constant(x) || opts$constructor == "next") {
return(NextMethod())
}
UseMethod(".cstr_construct.relational_relexpr_constant", structure(NA, class = opts$constructor))
}

Expand Down
4 changes: 3 additions & 1 deletion R/construct_function.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ opts_relational_relexpr_function <- function(constructor = c("relexpr_function",
.cstr_construct.relational_relexpr_function <- function(x, ...) {
# There is probably no need for you to modify this function at all
opts <- list(...)$opts$relational_relexpr_function %||% opts_relational_relexpr_function()
if (is_corrupted_relational_relexpr_function(x) || opts$constructor == "next") return(NextMethod())
if (is_corrupted_relational_relexpr_function(x) || opts$constructor == "next") {
return(NextMethod())
}
# This odd looking code dispatches to a method based on the name of
# the constructor rather than the class
UseMethod(".cstr_construct.relational_relexpr_function", structure(NA, class = opts$constructor))
Expand Down
4 changes: 3 additions & 1 deletion R/construct_reference.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ opts_relational_relexpr_reference <- function(constructor = c("relexpr_reference

.cstr_construct.relational_relexpr_reference <- function(x, ...) {
opts <- list(...)$opts$relational_relexpr_reference %||% opts_relational_relexpr_reference()
if (is_corrupted_relational_relexpr_reference(x) || opts$constructor == "next") return(NextMethod())
if (is_corrupted_relational_relexpr_reference(x) || opts$constructor == "next") {
return(NextMethod())
}
UseMethod(".cstr_construct.relational_relexpr_reference", structure(NA, class = opts$constructor))
}

Expand Down
4 changes: 3 additions & 1 deletion R/construct_window.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ opts_relational_relexpr_window <- function(constructor = c("relexpr_window", "ne

.cstr_construct.relational_relexpr_window <- function(x, ...) {
opts <- list(...)$opts$relational_relexpr_window %||% opts_relational_relexpr_window()
if (is_corrupted_relational_relexpr_window(x) || opts$constructor == "next") return(NextMethod())
if (is_corrupted_relational_relexpr_window(x) || opts$constructor == "next") {
return(NextMethod())
}
UseMethod(".cstr_construct.relational_relexpr_window", structure(NA, class = opts$constructor))
}

Expand Down
2 changes: 1 addition & 1 deletion R/count.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ count.duckplyr_df <- function(x, ..., wt = NULL, sort = FALSE, name = NULL, .dro

n <- tally_n(x, {{ wt }})

rel_try(call = list(name = "count", x = x, args = list(dots = enquos(...), wt = enquo(wt), sort = sort, name = if (!name_was_null) sym(name), .drop = .drop)),
rel_try(list(name = "count", x = x, args = list(dots = enquos(...), wt = enquo(wt), sort = sort, name = if (!name_was_null) sym(name), .drop = .drop)),
"count() needs all(is_name)" = !all(is_name),
"count() only implemented for .drop = TRUE" = !.drop,
"count() only implemented for sort = FALSE" = sort,
Expand Down
2 changes: 1 addition & 1 deletion R/cross_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
cross_join.duckplyr_df <- function(x, y, ..., copy = FALSE, suffix = c(".x", ".y")) {
# Our implementation
rel_try(
rel_try(NULL,
"No relational implementation for cross_join()" = TRUE,
{
return(out)
Expand Down
2 changes: 1 addition & 1 deletion R/distinct.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ distinct.duckplyr_df <- function(.data, ..., .keep_all = FALSE) {
dots <- enquos(..., .named = TRUE)

# Our implementation
rel_try(call = list(name = "distinct", x = .data, args = list(dots = dots, .keep_all = .keep_all)),
rel_try(list(name = "distinct", x = .data, args = list(dots = dots, .keep_all = .keep_all)),
"Implemented for all cases?" = FALSE,
{
# FIXME: avoid column duplication in a cleaner way
Expand Down
2 changes: 1 addition & 1 deletion R/do.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
do.duckplyr_df <- function(.data, ...) {
# Our implementation
rel_try(
rel_try(NULL,
"No relational implementation for do()" = TRUE,
{
return(out)
Expand Down
13 changes: 8 additions & 5 deletions R/explain.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#' @export
explain.duckplyr_df <- function(x, ...) {
rel_try({
rel <- duckdb_rel_from_df(x)
rel_explain(rel)
return(invisible())
})
rel_try(list(name = "explain", x = x),
"No restrictions" = FALSE,
{
rel <- duckdb_rel_from_df(x)
rel_explain(rel)
return(invisible())
}
)

writeLines("Can't convert to relational, fallback implementation will be used.")
invisible()
Expand Down
10 changes: 5 additions & 5 deletions R/fallback.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fallback_sitrep <- function() {

msg <- c(
fallback_txt_header(),

#
if (is.na(fallback_logging)) {
c("i" = "Fallback logging is not controlled and therefore disabled. Enable it with {.run Sys.setenv(DUCKPLYR_FALLBACK_COLLECT = 1)}, disable it with {.run Sys.setenv(DUCKPLYR_FALLBACK_COLLECT = 0)}.")
} else if (fallback_logging) {
Expand All @@ -89,15 +89,15 @@ fallback_sitrep <- function() {
} else {
c("x" = "Fallback logging is disabled.")
},

#
fallback_txt_uploading(fallback_uploading),

#
if (isTRUE(fallback_logging)) {
fallback_txt_sitrep_logs(fallback_logs)
},

#
fallback_txt_help(),

#
NULL
)

Expand Down
2 changes: 1 addition & 1 deletion R/filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ filter.duckplyr_df <- function(.data, ..., .by = NULL, .preserve = FALSE) {

by <- enquo(.by)

rel_try(call = list(name = "filter", x = .data, args = list(dots = dots, by = by, preserve = .preserve)),
rel_try(list(name = "filter", x = .data, args = list(dots = dots, by = by, preserve = .preserve)),
"Can't use relational with zero-column result set." = (length(.data) == 0),
"Can't use relational without filter conditions." = (length(dots) == 0),
"Can't use relational with grouped operation." = (!quo_is_null(by)), # (length(by$names) > 0),
Expand Down
2 changes: 1 addition & 1 deletion R/full_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ full_join.duckplyr_df <- function(x, y, by = NULL, copy = FALSE, suffix = c(".x"
y <- auto_copy(x, y, copy = copy)

# Our implementation
rel_try(call = list(name = "full_join", x = x, y = y, args = list(by = if(!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, keep = keep, na_matches = na_matches, multiple = multiple, relationship = relationship)),
rel_try(list(name = "full_join", x = x, y = y, args = list(by = if (!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, keep = keep, na_matches = na_matches, multiple = multiple, relationship = relationship)),
"No implicit cross joins for full_join()" = is_cross_by(by),
{
out <- rel_join_impl(x, y, by, "full", na_matches, suffix, keep, error_call)
Expand Down
2 changes: 1 addition & 1 deletion R/group_by.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
group_by.duckplyr_df <- function(.data, ..., .add = FALSE, .drop = group_by_drop_default(.data)) {
# Our implementation
rel_try(
rel_try(NULL,
# Always fall back to dplyr
"No relational implementation for group_by()" = TRUE,
{
Expand Down
2 changes: 1 addition & 1 deletion R/group_indices.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
group_indices.duckplyr_df <- function(.data, ...) {
# Our implementation
rel_try(
rel_try(NULL,
# Always fall back to dplyr
"No relational implementation for group_indices()" = TRUE,
{
Expand Down
2 changes: 1 addition & 1 deletion R/group_keys.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
group_keys.duckplyr_df <- function(.tbl, ...) {
# Our implementation
rel_try(
rel_try(NULL,
# Always fall back to dplyr
"No relational implementation for group_keys()" = TRUE,
{
Expand Down
4 changes: 2 additions & 2 deletions R/group_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ group_map.duckplyr_df <- function(.data, .f, ..., .keep = FALSE, keep = deprecat
}

# Our implementation
rel_try(
rel_try(NULL,
# Always fall back to dplyr
"No relational implementation for group_map()" = TRUE,
{
Expand All @@ -33,7 +33,7 @@ group_map.duckplyr_df <- function(.data, .f, ..., .keep = FALSE, keep = deprecat
} else {
group_split(.data)
}
keys <- group_keys(.data)
keys <- group_keys(.data)
group_keys <- map(seq_len(nrow(keys)), function(i) keys[i, , drop = FALSE])

if (length(chunks)) {
Expand Down
2 changes: 1 addition & 1 deletion R/group_modify.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ group_modify.duckplyr_df <- function(.data, .f, ..., .keep = FALSE, keep = depre
}

# Our implementation
rel_try(
rel_try(NULL,
# Always fall back to dplyr
"No relational implementation for group_modify()" = TRUE,
{
Expand Down
2 changes: 1 addition & 1 deletion R/group_nest.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
group_nest.duckplyr_df <- function(.tbl, ..., .key = "data", keep = FALSE) {
# Our implementation
rel_try(
rel_try(NULL,
# Always fall back to dplyr
"No relational implementation for group_nest()" = TRUE,
{
Expand Down
2 changes: 1 addition & 1 deletion R/group_size.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
group_size.duckplyr_df <- function(x) {
# Our implementation
rel_try(
rel_try(NULL,
# Always fall back to dplyr
"No relational implementation for group_size()" = TRUE,
{
Expand Down
2 changes: 1 addition & 1 deletion R/group_split.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ group_split.duckplyr_df <- function(.tbl, ..., .keep = TRUE, keep = deprecated()
}

# Our implementation
rel_try(
rel_try(NULL,
# Always fall back to dplyr
"No relational implementation for group_split()" = TRUE,
{
Expand Down
2 changes: 1 addition & 1 deletion R/group_trim.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
group_trim.duckplyr_df <- function(.tbl, .drop = group_by_drop_default(.tbl)) {
# Our implementation
rel_try(
rel_try(NULL,
# Always fall back to dplyr
"No relational implementation for group_trim()" = TRUE,
{
Expand Down
2 changes: 1 addition & 1 deletion R/groups.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
groups.duckplyr_df <- function(x) {
# Our implementation
rel_try(
rel_try(NULL,
# Always fall back to dplyr
"No relational implementation for groups()" = TRUE,
{
Expand Down
6 changes: 3 additions & 3 deletions R/handle_desc.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ handle_desc <- function(dots) {
for (i in seq_along(dots)) {
expr <- quo_get_expr(dots[[i]])

if (!is.call(expr)) next
if (expr[[1]] != "desc") next
if (!is.call(expr)) next
if (expr[[1]] != "desc") next

# Check that desc is called with a single argument
# (dplyr::desc() accepts only one argument)
if (length(expr) > 2) cli::cli_abort("`desc()` must be called with exactly one argument.")

ascending[i] <- FALSE
dots[[i]] <- new_quosure(expr[[2]], env = quo_get_env(dots[[i]]))
dots[[i]] <- new_quosure(expr[[2]], env = quo_get_env(dots[[i]]))
}

list(dots = dots, ascending = ascending)
Expand Down
2 changes: 1 addition & 1 deletion R/head.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
head.duckplyr_df <- function(x, n = 6L, ...) {
stopifnot(is_integerish(n))

rel_try(call = list(name = "head", x = x, args = list(n = n)),
rel_try(list(name = "head", x = x, args = list(n = n)),
"Can't process negative n" = (n < 0),
{
rel <- duckdb_rel_from_df(x)
Expand Down
2 changes: 1 addition & 1 deletion R/inner_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inner_join.duckplyr_df <- function(x, y, by = NULL, copy = FALSE, suffix = c(".x
y <- auto_copy(x, y, copy = copy)

# Our implementation
rel_try(call = list(name = "inner_join", x = x, y = y, args = list(by = if(!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, keep = keep, na_matches = na_matches, multiple = multiple, unmatched = unmatched, relationship = relationship)),
rel_try(list(name = "inner_join", x = x, y = y, args = list(by = if (!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, keep = keep, na_matches = na_matches, multiple = multiple, unmatched = unmatched, relationship = relationship)),
"No implicit cross joins for inner_join()" = is_cross_by(by),
{
out <- rel_join_impl(x, y, by, "inner", na_matches, suffix, keep, error_call)
Expand Down
2 changes: 1 addition & 1 deletion R/intersect.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ intersect.duckplyr_df <- function(x, y, ...) {
y_names <- x_names
}

rel_try(call = list(name = "intersect", x = x, y = y),
rel_try(list(name = "intersect", x = x, y = y),
"No duplicate names" = !identical(x_names, y_names) && anyDuplicated(x_names) && anyDuplicated(y_names),
"Tables of different width" = length(x_names) != length(y_names),
"Name mismatch" = !identical(x_names, y_names) && !all(y_names %in% x_names),
Expand Down
16 changes: 8 additions & 8 deletions R/join.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
rel_join_impl <- function(
x,
y,
by,
join,
na_matches,
suffix = c(".x", ".y"),
keep = NULL,
error_call = caller_env()
x,
y,
by,
join,
na_matches,
suffix = c(".x", ".y"),
keep = NULL,
error_call = caller_env()
) {
mutating <- !(join %in% c("semi", "anti"))

Expand Down
2 changes: 1 addition & 1 deletion R/left_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ left_join.duckplyr_df <- function(x, y, by = NULL, copy = FALSE, suffix = c(".x"
y <- auto_copy(x, y, copy = copy)

# Our implementation
rel_try(call = list(name = "left_join", x = x, y = y, args = list(by = if(!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, keep = keep, na_matches = na_matches, multiple = multiple, unmatched = unmatched, relationship = relationship)),
rel_try(list(name = "left_join", x = x, y = y, args = list(by = if (!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, keep = keep, na_matches = na_matches, multiple = multiple, unmatched = unmatched, relationship = relationship)),
"No implicit cross joins for left_join()" = is_cross_by(by),
{
out <- rel_join_impl(x, y, by, "left", na_matches, suffix, keep, error_call)
Expand Down
2 changes: 1 addition & 1 deletion R/mutate.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mutate.duckplyr_df <- function(.data, ..., .by = NULL, .keep = c("all", "used",
by_names <- eval_select_by(by_arg, .data)

# Our implementation
rel_try(call = list(name = "mutate", x = .data, args = list(dots = enquos(...), .by = by_arg, .keep = .keep)),
rel_try(list(name = "mutate", x = .data, args = list(dots = enquos(...), .by = by_arg, .keep = .keep)),
"Implemented for all cases?" = FALSE,
{
rel <- duckdb_rel_from_df(.data)
Expand Down
2 changes: 1 addition & 1 deletion R/n_groups.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
n_groups.duckplyr_df <- function(x) {
# Our implementation
rel_try(
rel_try(NULL,
# Always fall back to dplyr
"No relational implementation for n_groups()" = TRUE,
{
Expand Down
2 changes: 1 addition & 1 deletion R/nest_by.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @export
nest_by.duckplyr_df <- function(.data, ..., .key = "data", .keep = FALSE) {
# Our implementation
rel_try(
rel_try(NULL,
"No relational implementation for nest_by()" = TRUE,
{
return(out)
Expand Down
Loading

0 comments on commit a618f03

Please sign in to comment.