Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upkeep #153

Merged
merged 7 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
# usethis::use_github_action("check-standard")
on:
schedule:
- cron: '0 0 1 * *'
push:
branches:
- main
- master
branches: [main, master]
pull_request:
branches:
- main
- master
branches: [main, master]

name: R-CMD-check

Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches:
- main
- master
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

Expand All @@ -14,6 +19,8 @@ jobs:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3

Expand Down
62 changes: 43 additions & 19 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
@@ -1,55 +1,79 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
issue_comment:
types: [created]

name: Commands

jobs:
document:
if: startsWith(github.event.comment.body, '/document')
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }}
name: document
runs-on: macOS-latest
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/pr-fetch@v1
- uses: actions/checkout@v3

- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: r-lib/actions/setup-r@v2
- name: Install dependencies
run: Rscript -e 'install.packages(c("remotes", "roxygen2"))' -e 'remotes::install_deps(dependencies = TRUE)'
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::roxygen2
needs: pr-document

- name: Document
run: Rscript -e 'roxygen2::roxygenise()'
run: roxygen2::roxygenise()
shell: Rscript {0}

- name: commit
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git add man/\* NAMESPACE
git commit -m 'Document'
- uses: r-lib/actions/pr-push@v1

- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

style:
if: startsWith(github.event.comment.body, '/style')
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }}
name: style
runs-on: macOS-latest
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/pr-fetch@v1
- uses: actions/checkout@v3

- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

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

- name: Install dependencies
run: Rscript -e 'install.packages("styler")'
run: install.packages("styler")
shell: Rscript {0}

- name: Style
run: Rscript -e 'styler::style_pkg()'
run: styler::style_pkg()
shell: Rscript {0}

- name: commit
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git add \*.R
git commit -m 'Style'
- uses: r-lib/actions/pr-push@v1

- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
60 changes: 28 additions & 32 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,54 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches:
- main
- master
branches: [main, master]
pull_request:
branches:
- main
- master
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
env:
RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

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

- uses: r-lib/actions/setup-r@v2
id: install-r

- name: Install pak and query dependencies
run: |
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds")
shell: Rscript {0}
with:
use-public-rspm: true

- name: Restore R package cache
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}
restore-keys: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1-
extra-packages: any::covr
needs: coverage

- name: Install system dependencies
if: runner.os == 'Linux'
- name: Test coverage
run: |
pak::local_system_requirements(execute = TRUE)
pak::pkg_system_requirements("covr", execute = TRUE)
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- name: Install dependencies
- name: Show testthat output
if: always()
run: |
pak::local_install_dev_deps(upgrade = TRUE)
pak::pkg_install("covr")
shell: Rscript {0}
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Test coverage
run: covr::codecov()
shell: Rscript {0}
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
10 changes: 3 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Imports:
recipes (>= 1.0.4),
rsample,
dplyr (>= 1.0.0),
ggplot2,
ggplot2 (>= 3.4.0),
forcats,
stringr,
plotly,
Expand All @@ -35,15 +35,14 @@ Imports:
tidyr (>= 1.1.0),
xts (>= 0.9-7),
zoo (>= 1.7-14),
rlang (>= 0.4.11),
rlang (>= 1.1.1),
tidyselect (>= 1.1.0),
slider,
anytime,
timeDate,
forecast,
tsfeatures,
hms,
assertthat,
generics,
tidymodels
Suggests:
Expand All @@ -61,10 +60,7 @@ Suggests:
fracdiff,
timeSeries,
tseries,
trelliscopejs,
roxygen2,
covr
trelliscopejs
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
VignetteBuilder: knitr

2 changes: 1 addition & 1 deletion R/augment-tk_augment_differences.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ tk_augment_differences.grouped_df <- function(.data,
.names = .names
)
)) %>%
dplyr::select(-data) %>%
dplyr::select(-"data") %>%
tidyr::unnest(cols = nested.col) %>%
dplyr::group_by_at(.vars = group_names)
}
Expand Down
2 changes: 1 addition & 1 deletion R/augment-tk_augment_fourier.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ tk_augment_fourier.grouped_df <- function(.data,
.names = .names
)
)) %>%
dplyr::select(-data) %>%
dplyr::select(-"data") %>%
tidyr::unnest(cols = nested.col) %>%
dplyr::group_by_at(.vars = group_names)
}
Expand Down
4 changes: 2 additions & 2 deletions R/diagnostics-tk_anomaly_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ iqr_vec <- function(x, alpha = 0.05, max_anoms = 0.2, verbose = FALSE) {
abs_diff_upper = ifelse(value >= limit_upper, abs(value - limit_upper), 0),
max_abs_diff = ifelse(abs_diff_lower > abs_diff_upper, abs_diff_lower, abs_diff_upper)
) %>%
dplyr::select(index, dplyr::everything()) %>%
dplyr::relocate(index) %>%
dplyr::select(-c(abs_diff_lower, abs_diff_upper)) %>%
# Sort by absolute distance from centerline of limits
dplyr::mutate(
Expand Down Expand Up @@ -284,7 +284,7 @@ iqr_vec <- function(x, alpha = 0.05, max_anoms = 0.2, verbose = FALSE) {
} else {
# All outliers, pick last limits
limit_tbl <- vals_tbl %>%
dplyr::slice(n())
dplyr::slice_tail(n = 1)
limits_vec <- c(
limit_lower = limit_tbl$limit_lower,
limit_upper = limit_tbl$limit_upper
Expand Down
2 changes: 1 addition & 1 deletion R/diagnostics-tk_stl_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ tk_stl_diagnostics.grouped_df <- function(.data, .date_var, .value,
.message = .message
)
)) %>%
dplyr::select(-data) %>%
dplyr::select(-"data") %>%
tidyr::unnest(cols = nested.col) %>%
dplyr::group_by_at(.vars = group_names)

Expand Down
6 changes: 2 additions & 4 deletions R/dplyr-pad_by_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ pad_by_time <- function(.data, .date_var, .by = "auto",
.fill_na_direction = c("none", "down", "up", "downup", "updown"),
.start_date = NULL, .end_date = NULL) {

if (!tolower(.fill_na_direction[1]) %in% c("none", "down", "up", "downup", "updown")) {
rlang::abort("'.fill_na_direction' must be one of c('none', 'down', 'up', 'downup', 'updown')")
}
rlang::arg_match(.fill_na_direction)

if (rlang::quo_is_missing(rlang::enquo(.date_var))) {
date_var_text <- tk_get_timeseries_variables(.data)[1]
Expand Down Expand Up @@ -296,7 +294,7 @@ padder <- function(.data, .date_var, .by = "auto", .pad_value = NA, .fill_na_dir

# Drop check_row_exists column
ret <- ret %>%
dplyr::select(-check_row_exists)
dplyr::select(-"check_row_exists")

# Fill NA
if (.fill_na_direction != "none") {
Expand Down
20 changes: 12 additions & 8 deletions R/dplyr-slidify.R
Original file line number Diff line number Diff line change
Expand Up @@ -245,26 +245,30 @@ slider_2 <- function(..., .slider_fun, .f, .period, .align, .partial, .unlist) {
check_dots <- function(x, .period) {

# The user must have passed something to be passed on to .f
assertthat::assert_that(length(x) > 0,
msg = "At least 1 data argument must be supplied to be
passed on to the rolling function")
if (length(x) == 0) {
stop("At least 1 data argument must be supplied to be
passed on to the rolling function", call. = FALSE)
}


# The .period must be smaller than the length of the data
assertthat::assert_that(.period <= length(x[[1]]),
msg = "Cannot roll apply with a .period larger than the
if (any(.period > length(x[[1]]))) {
stop(call. = FALSE, "Cannot roll apply with a .period larger than the
length of the data")
}


# Length of every element of .dots should be the same
# Only data used in the rolling should be in .dots
# Optional args should be specified in the slidify call
for(i in 1:length(x)) {
assertthat::assert_that(length(x[[i]]) == length(x[[1]]),
msg = "Arguments supplied to the rolling version
lens <- lengths(x)
n_distinct_length_x <- length(unique(lens))
if (n_distinct_length_x != 1) {
stop(call. = FALSE, "Arguments supplied to the rolling version
of the function should be data of the same length.
Optional arguments should be specified when creating
the rolling version with `slidify()`")
}
TRUE
}

8 changes: 4 additions & 4 deletions R/get-tk_get_holiday_signature.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ get_holiday_signature <- function(idx,

# Setup
idx <- lubridate::as_date(idx)
years <- lubridate::year(idx) %>% unique()
locale_set <- locale_set %>% tolower()
exchange_set <- exchange_set %>% tolower()
years <- unique(lubridate::year(idx))
locale_set <- tolower(locale_set)
exchange_set <- tolower(exchange_set)

if (any("all" %in% locale_set)) locale_set <- "all"
if (any("all" %in% exchange_set)) exchange_set <- "all"
Expand All @@ -150,7 +150,7 @@ get_holiday_signature <- function(idx,
if (any("none" %in% exchange_set)) exchange_set <- "none"

initial_index_tbl <- tibble::tibble(index = idx)
unique_index_tbl <- initial_index_tbl %>% dplyr::distinct()
unique_index_tbl <- dplyr::distinct(initial_index_tbl)

# HOLIDAY & LOCALE FEATURES ----

Expand Down
Loading