Skip to content

Commit

Permalink
MINOR: [R] Fix lint warnings and run styler over everything (#14153)
Browse files Browse the repository at this point in the history
Authored-by: Neal Richardson <neal.p.richardson@gmail.com>
Signed-off-by: Neal Richardson <neal.p.richardson@gmail.com>
  • Loading branch information
nealrichardson committed Sep 16, 2022
1 parent e3be15f commit 6bc2e01
Show file tree
Hide file tree
Showing 18 changed files with 100 additions and 127 deletions.
2 changes: 1 addition & 1 deletion r/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Imports:
utils,
vctrs
Roxygen: list(markdown = TRUE, r6 = FALSE, load = "source")
RoxygenNote: 7.2.0
RoxygenNote: 7.2.1
Config/testthat/edition: 3
VignetteBuilder: knitr
Suggests:
Expand Down
1 change: 0 additions & 1 deletion r/R/arrowExports.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions r/R/dplyr-datetime-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,10 @@ parse_period_unit <- function(x) {
str_unit <- substr(x, capture_start[[2]], capture_end[[2]])
str_multiple <- substr(x, capture_start[[1]], capture_end[[1]])

known_units <- c("nanosecond", "microsecond", "millisecond", "second",
"minute", "hour", "day", "week", "month", "quarter", "year")
known_units <- c(
"nanosecond", "microsecond", "millisecond", "second",
"minute", "hour", "day", "week", "month", "quarter", "year"
)

# match the period unit
str_unit_start <- substr(str_unit, 1, 3)
Expand All @@ -464,7 +466,7 @@ parse_period_unit <- function(x) {
if (capture_length[[1]] == 0) {
multiple <- 1L

# otherwise parse the multiple
# otherwise parse the multiple
} else {
multiple <- as.numeric(str_multiple)

Expand Down
28 changes: 15 additions & 13 deletions r/R/dplyr-funcs-doc.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@
#' as `arrow_ascii_is_decimal`.
#'
#' ## arrow
#'
#'
#' * [`add_filename()`][arrow::add_filename()]
#' * [`cast()`][arrow::cast()]
#'
#' ## base
#'
#'
#' * [`-`][-()]
#' * [`!`][!()]
#' * [`!=`][!=()]
Expand Down Expand Up @@ -179,13 +179,15 @@
#' * [`trunc()`][base::trunc()]
#'
#' ## bit64
#'
#'
#' * [`as.integer64()`][bit64::as.integer64()]
#' * [`is.integer64()`][bit64::is.integer64()]
#'
#' ## dplyr
#'
#' * [`across()`][dplyr::across()]: only supported inside `mutate()`, `summarize()`, and `arrange()`; purrr-style lambda functions and use of `where()` selection helper not yet supported
#'
#' * [`across()`][dplyr::across()]: supported inside `mutate()`, `summarize()`, `group_by()`, and `arrange()`;
#' purrr-style lambda functions
#' and use of `where()` selection helper not yet supported
#' * [`between()`][dplyr::between()]
#' * [`case_when()`][dplyr::case_when()]
#' * [`coalesce()`][dplyr::coalesce()]
Expand All @@ -195,7 +197,7 @@
#' * [`n_distinct()`][dplyr::n_distinct()]
#'
#' ## lubridate
#'
#'
#' * [`am()`][lubridate::am()]
#' * [`as_date()`][lubridate::as_date()]
#' * [`as_datetime()`][lubridate::as_datetime()]
Expand Down Expand Up @@ -270,30 +272,30 @@
#' * [`yq()`][lubridate::yq()]
#'
#' ## methods
#'
#'
#' * [`is()`][methods::is()]
#'
#' ## rlang
#'
#'
#' * [`is_character()`][rlang::is_character()]
#' * [`is_double()`][rlang::is_double()]
#' * [`is_integer()`][rlang::is_integer()]
#' * [`is_list()`][rlang::is_list()]
#' * [`is_logical()`][rlang::is_logical()]
#'
#' ## stats
#'
#'
#' * [`median()`][stats::median()]
#' * [`quantile()`][stats::quantile()]
#' * [`sd()`][stats::sd()]
#' * [`var()`][stats::var()]
#'
#' ## stringi
#'
#'
#' * [`stri_reverse()`][stringi::stri_reverse()]
#'
#' ## stringr
#'
#'
#' * [`str_c()`][stringr::str_c()]: the `collapse` argument is not yet supported
#' * [`str_count()`][stringr::str_count()]
#' * [`str_detect()`][stringr::str_detect()]
Expand All @@ -313,11 +315,11 @@
#' * [`str_trim()`][stringr::str_trim()]
#'
#' ## tibble
#'
#'
#' * [`tibble()`][tibble::tibble()]
#'
#' ## tidyselect
#'
#'
#' * [`all_of()`][tidyselect::all_of()]
#' * [`contains()`][tidyselect::contains()]
#' * [`ends_with()`][tidyselect::ends_with()]
Expand Down
3 changes: 1 addition & 2 deletions r/R/dplyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ dim.arrow_dplyr_query <- function(x) {

#' @export
unique.arrow_dplyr_query <- function(x, incomparables = FALSE, fromLast = FALSE, ...) {

if (isTRUE(incomparables)) {
arrow_not_supported("`unique()` with `incomparables = TRUE`")
}
Expand Down Expand Up @@ -262,7 +261,7 @@ tail.arrow_dplyr_query <- function(x, n = 6L, ...) {
#' mtcars %>%
#' arrow_table() %>%
#' filter(mpg > 20) %>%
#' mutate(x = gear/carb) %>%
#' mutate(x = gear / carb) %>%
#' show_exec_plan()
show_exec_plan <- function(x) {
adq <- as_adq(x)
Expand Down
12 changes: 6 additions & 6 deletions r/data-raw/docgen.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ render_pkg <- function(df, pkg) {
pull()
# Add header
bullets <- c(
paste("##", pkg),
"",
paste0("## ", pkg, "\n#'"),
bullets
)
paste("#'", bullets, collapse = "\n")
Expand All @@ -129,10 +128,11 @@ docs <- arrow:::.cache$docs

# across() is handled by manipulating the quosures, not by nse_funcs
docs[["dplyr::across"]] <- c(
# TODO(ARROW-17387, ARROW-17389, ARROW-17390)
"only supported inside `mutate()`, `summarize()`, and `arrange()`;",
# TODO(ARROW-17366)
# TODO(ARROW-17387, ARROW-17389, ARROW-17390): other verbs
"supported inside `mutate()`, `summarize()`, `group_by()`, and `arrange()`;",
# TODO(ARROW-17366): do ~
"purrr-style lambda functions",
# TODO(ARROW-17384): implement where
"and use of `where()` selection helper not yet supported"
)
# desc() is a special helper handled inside of arrange()
Expand All @@ -154,7 +154,7 @@ fun_df <- tibble::tibble(
# We will list operators under "base" (everything else must be pkg::fun)
pkg = if_else(has_pkg, pkg, "base"),
# Flatten notes to a single string
notes = map_chr(notes, ~ paste(., collapse = " "))
notes = map_chr(notes, ~ paste(., collapse = "\n#' "))
) %>%
arrange(pkg, fun)

Expand Down
4 changes: 3 additions & 1 deletion r/man/acero.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion r/man/show_exec_plan.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion r/tests/testthat/test-Table.R
Original file line number Diff line number Diff line change
Expand Up @@ -692,5 +692,4 @@ test_that("num_rows method not susceptible to integer overflow", {
expect_type(big_table$num_rows, "double")

expect_identical(big_string_array$data()$buffers[[3]]$size, 2148007936)

})
2 changes: 1 addition & 1 deletion r/tests/testthat/test-compute.R
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ test_that("nested exec plans can contain user-defined functions", {
on.exit(unregister_binding("times_32", update_cache = TRUE))

stream_plan_with_udf <- function() {
record_batch(a = 1:1000) %>%
record_batch(a = 1:1000) %>%
dplyr::mutate(b = times_32(a)) %>%
as_record_batch_reader() %>%
as_arrow_table()
Expand Down
40 changes: 20 additions & 20 deletions r/tests/testthat/test-dataset-dplyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ test_that("show_exec_plan(), show_query() and explain() with datasets", {
ds %>%
show_exec_plan(),
regexp = paste0(
"ExecPlan with .* nodes:.*", # boiler plate for ExecPlan
"ProjectNode.*", # output columns
"SourceNode" # entry point
"ExecPlan with .* nodes:.*", # boiler plate for ExecPlan
"ProjectNode.*", # output columns
"SourceNode" # entry point
)
)

Expand All @@ -369,11 +369,11 @@ test_that("show_exec_plan(), show_query() and explain() with datasets", {
filter(integer > 6L & part == 1) %>%
show_exec_plan(),
regexp = paste0(
"ExecPlan with .* nodes:.*", # boiler plate for ExecPlan
"ProjectNode.*", # output columns
"FilterNode.*", # filter node
"int > 6.*cast.*", # filtering expressions + auto-casting of part
"SourceNode" # entry point
"ExecPlan with .* nodes:.*", # boiler plate for ExecPlan
"ProjectNode.*", # output columns
"FilterNode.*", # filter node
"int > 6.*cast.*", # filtering expressions + auto-casting of part
"SourceNode" # entry point
)
)

Expand All @@ -384,13 +384,13 @@ test_that("show_exec_plan(), show_query() and explain() with datasets", {
summarise(avg = mean(int)) %>%
show_exec_plan(),
regexp = paste0(
"ExecPlan with .* nodes:.*", # boiler plate for ExecPlan
"ProjectNode.*", # output columns
"GroupByNode.*", # group by node
"keys=.*part.*", # key for aggregations
"aggregates=.*hash_mean.*", # aggregations
"ProjectNode.*", # input columns
"SourceNode" # entry point
"ExecPlan with .* nodes:.*", # boiler plate for ExecPlan
"ProjectNode.*", # output columns
"GroupByNode.*", # group by node
"keys=.*part.*", # key for aggregations
"aggregates=.*hash_mean.*", # aggregations
"ProjectNode.*", # input columns
"SourceNode" # entry point
)
)

Expand All @@ -401,12 +401,12 @@ test_that("show_exec_plan(), show_query() and explain() with datasets", {
arrange(chr) %>%
show_exec_plan(),
regexp = paste0(
"ExecPlan with .* nodes:.*", # boiler plate for ExecPlan
"ExecPlan with .* nodes:.*", # boiler plate for ExecPlan
"OrderBySinkNode.*chr.*ASC.*", # arrange goes via the OrderBy sink node
"ProjectNode.*", # output columns
"FilterNode.*", # filter node
"filter=lgl.*", # filtering expression
"SourceNode" # entry point
"ProjectNode.*", # output columns
"FilterNode.*", # filter node
"filter=lgl.*", # filtering expression
"SourceNode" # entry point
)
)

Expand Down
4 changes: 2 additions & 2 deletions r/tests/testthat/test-dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ test_that("map_batches", {
test_that("map_batches with explicit schema", {
fun_with_dots <- function(batch, first_col, first_col_val) {
record_batch(
!! first_col := first_col_val,
!!first_col := first_col_val,
b = batch$a$cast(float64())
)
}
Expand Down Expand Up @@ -736,7 +736,7 @@ test_that("map_batches with explicit schema", {
test_that("map_batches without explicit schema", {
fun_with_dots <- function(batch, first_col, first_col_val) {
record_batch(
!! first_col := first_col_val,
!!first_col := first_col_val,
b = batch$a$cast(float64())
)
}
Expand Down
1 change: 0 additions & 1 deletion r/tests/testthat/test-dplyr-across.R
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,4 @@ test_that("expand_across correctly expands quosures", {
regexp = "`.names` specification must produce (number of columns * number of functions) names.",
fixed = TRUE
)

})
Loading

0 comments on commit 6bc2e01

Please sign in to comment.