Skip to content

Commit

Permalink
Upkeep (#422)
Browse files Browse the repository at this point in the history
* RStudio -> Posit
* use_tidy_github_actions()
* Re-document
* Fix method<->generic mismatches
  • Loading branch information
hadley authored Mar 21, 2023
1 parent f629a44 commit 2750fb7
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 51 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,27 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
# Use 3.6 to trigger usage of RTools35
- {os: windows-latest, r: '3.6'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}

# Use older ubuntu to maximise backward compatibility
- {os: ubuntu-18.04, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-18.04, r: 'release'}
- {os: ubuntu-18.04, r: 'oldrel-1'}
- {os: ubuntu-18.04, r: 'oldrel-2'}
- {os: ubuntu-18.04, r: 'oldrel-3'}
- {os: ubuntu-18.04, r: 'oldrel-4'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'oldrel-4'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -39,7 +39,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@4.1.4
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
clean: false
branch: gh-pages
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/pr-fetch@v2
with:
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/pr-fetch@v2
with:
Expand Down
23 changes: 21 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
Expand All @@ -27,5 +27,24 @@ jobs:
needs: coverage

- name: Test coverage
run: covr::codecov(quiet = FALSE)
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ Package: dtplyr
Title: Data Table Back-End for 'dplyr'
Version: 1.3.0.9000
Authors@R: c(
person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("cre", "aut")),
person("Hadley", "Wickham", , "hadley@posit.co", role = c("cre", "aut")),
person("Maximilian", "Girlich", role = "aut"),
person("Mark", "Fairbanks", role = "aut"),
person("Ryan", "Dickerson", role = "aut"),
person("RStudio", role = c("cph", "fnd"))
person("Posit Software, PBC", role = c("cph", "fnd"))
)
Description: Provides a data.table backend for 'dplyr'. The goal of
'dtplyr' is to allow you to write 'dplyr' code that is automatically
Expand Down
20 changes: 10 additions & 10 deletions R/count.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' This is a method for the dplyr [count()] generic. It is translated using
#' `.N` in the `j` argument, and supplying groups to `keyby` as appropriate.
#'
#' @param .data A [lazy_dt()]
#' @param x A [lazy_dt()]
#' @inheritParams dplyr::count
#' @importFrom dplyr count
#' @export
Expand All @@ -14,12 +14,12 @@
#' dt %>% count(species)
#' dt %>% count(species, sort = TRUE)
#' dt %>% count(species, wt = mass, sort = TRUE)
count.dtplyr_step <- function(.data, ..., wt = NULL, sort = FALSE, name = NULL) {
count.dtplyr_step <- function(x, ..., wt = NULL, sort = FALSE, name = NULL) {
if (!missing(...)) {
out <- group_by(.data, ..., .add = TRUE)
out <- group_by(x, ..., .add = TRUE)
.groups <- "drop"
} else {
out <- .data
out <- x
.groups <- "keep"
}

Expand All @@ -30,21 +30,21 @@ count.dtplyr_step <- function(.data, ..., wt = NULL, sort = FALSE, name = NULL)

#' @importFrom dplyr add_count
#' @export
add_count.dtplyr_step <- function(.data, ..., wt = NULL, sort = FALSE, name = NULL) {
add_count.dtplyr_step <- function(x, ..., wt = NULL, sort = FALSE, name = NULL) {
if (!missing(...)) {
out <- group_by(.data, ..., .add = TRUE)
out <- group_by(x, ..., .add = TRUE)
} else {
out <- .data
out <- x
}
out <- dplyr::add_tally(out, wt = !!enquo(wt), sort = sort, name = name)
out <- group_by(out, !!!syms(group_vars(.data)))
out <- group_by(out, !!!syms(group_vars(x)))
out
}

#' @importFrom dplyr tally
#' @export
tally.dtplyr_step <- function(.data, wt = NULL, sort = FALSE, name = NULL) {
tally_count(.data, {{ wt }}, sort, name, "drop_last")
tally.dtplyr_step <- function(x, wt = NULL, sort = FALSE, name = NULL) {
tally_count(x, {{ wt }}, sort, name, "drop_last")
}

# Helpers -----------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions R/step-group.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ can_step_group_return_early <- function(parent, groups, arrange) {
#' @importFrom dplyr ungroup
#' @export
#' @rdname group_by.dtplyr_step
ungroup.dtplyr_step <- function(.data, ...) {
ungroup.dtplyr_step <- function(x, ...) {
if (missing(...)) {
step_group(.data, groups = character())
step_group(x, groups = character())
} else {
old_groups <- group_vars(.data)
to_remove <- tidyselect::vars_select(.data$vars, ...)
old_groups <- group_vars(x)
to_remove <- tidyselect::vars_select(x$vars, ...)
new_groups <- setdiff(old_groups, to_remove)
step_group(.data, groups = new_groups)
step_group(x, groups = new_groups)
}
}

12 changes: 6 additions & 6 deletions R/step-modify.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dt_call.dtplyr_step_modify <- function(x, needs_copy = x$needs_copy) {
#' These are methods for the dplyr [group_map()] and [group_modify()] generics.
#' They are both translated to `[.data.table`.
#'
#' @param .tbl A [lazy_dt()]
#' @param .data A [lazy_dt()]
#' @param .f The name of a two argument function. The first argument is passed
#' `.SD`,the data.table representing the current group; the second argument
#' is passed `.BY`, a list giving the current values of the grouping
Expand All @@ -49,23 +49,23 @@ dt_call.dtplyr_step_modify <- function(x, needs_copy = x$needs_copy) {
#' dt %>%
#' group_by(cyl) %>%
#' group_map(head, n = 2L)
group_modify.dtplyr_step <- function(.tbl, .f, ..., keep = FALSE) {
group_modify.dtplyr_step <- function(.data, .f, ..., keep = FALSE) {
if (!missing(keep)) {
abort("`keep` is not supported for lazy data tables")
}

.f <- ensym(.f)
args <- enquos(...)

step_modify(.tbl, fun = .f, args = args)
step_modify(.data, fun = .f, args = args)
}

#' @importFrom dplyr group_map
#' @rdname group_modify.dtplyr_step
#' @export
group_map.dtplyr_step <- function(.tbl, .f, ..., keep = FALSE) {
group_map.dtplyr_step <- function(.data, .f, ..., keep = FALSE) {
.f <- as_function(.f, caller_env())

dt <- as.data.table(.tbl)
dt[, list(list(.f(.SD, .BY, ...))), by = eval(.tbl$groups)]$V1
dt <- as.data.table(.data)
dt[, list(list(.f(.SD, .BY, ...))), by = eval(.data$groups)]$V1
}
8 changes: 6 additions & 2 deletions R/step-subset-slice.R
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ sample_int <- function(n, size, replace = FALSE, wt = NULL) {
sample_n.dtplyr_step <- function(tbl,
size,
replace = FALSE,
weight = NULL
weight = NULL,
.env = NULL,
...
) {
weight <- enexpr(weight)
step_subset_i(tbl, i = sample_call(size, replace, weight))
Expand All @@ -235,7 +237,9 @@ sample_n.dtplyr_step <- function(tbl,
sample_frac.dtplyr_step <- function(tbl,
size = 1,
replace = FALSE,
weight = NULL
weight = NULL,
.env = NULL,
...
) {
weight <- enexpr(weight)
step_subset_i(tbl, i = sample_call(expr(.N * !!size), replace, weight))
Expand Down
6 changes: 3 additions & 3 deletions R/step.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ as_tibble.dtplyr_step <- function(x, ..., .name_repair = "check_unique") {

#' @export
#' @importFrom dplyr pull
pull.dtplyr_step <- function(.data, var = -1, name = NULL) {
pull.dtplyr_step <- function(.data, var = -1, name = NULL, ...) {
var <- sym(tidyselect::vars_pull(.data$vars, !!enquo(var)))

.data <- ungroup(.data)
Expand Down Expand Up @@ -210,7 +210,7 @@ glimpse.dtplyr_step <- function(x, width = NULL, ...) {

#' @importFrom dplyr show_query
#' @export
show_query.dtplyr_step <- function(x) {
show_query.dtplyr_step <- function(x, ...) {
dt_call(x)
}

Expand Down Expand Up @@ -239,6 +239,6 @@ dt_has_computation <- function(x) {
UseMethod("dt_has_computation")
}
#' @export
dt_has_computation.dtplyr_step <- function(x, needs_copy = x$needs_copy) {
dt_has_computation.dtplyr_step <- function(x) {
TRUE
}
4 changes: 2 additions & 2 deletions man/count.dtplyr_step.Rd

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

4 changes: 2 additions & 2 deletions man/dtplyr-package.Rd

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

4 changes: 3 additions & 1 deletion man/group_by.dtplyr_step.Rd

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

6 changes: 3 additions & 3 deletions man/group_modify.dtplyr_step.Rd

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

0 comments on commit 2750fb7

Please sign in to comment.