Skip to content

Commit 84cf7b2

Browse files
authored
Merge branch 'main' into enumerate-steps-layers-print
2 parents 03ae9a9 + 015b0ea commit 84cf7b2

File tree

121 files changed

+1894
-4144
lines changed

Some content is hidden

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

121 files changed

+1894
-4144
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# using styler at all
2+
aca7d5e7b66d8bac9d9fbcec3acdb98a087d58fa
3+
f12fcc2bf3fe0a75ba2b10eaaf8a1f1d22486a17

.github/workflows/styler.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
workflow_dispatch:
5+
pullrequest:
6+
paths:
7+
[
8+
"**.[rR]",
9+
"**.[qrR]md",
10+
"**.[rR]markdown",
11+
"**.[rR]nw",
12+
"**.[rR]profile",
13+
]
14+
15+
name: Style
16+
17+
jobs:
18+
style:
19+
runs-on: ubuntu-latest
20+
env:
21+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
22+
steps:
23+
- name: Checkout repo
24+
uses: actions/checkout@v3
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup R
29+
uses: r-lib/actions/setup-r@v2
30+
with:
31+
use-public-rspm: true
32+
33+
- name: Install dependencies
34+
uses: r-lib/actions/setup-r-dependencies@v2
35+
with:
36+
extra-packages: any::styler, any::roxygen2
37+
needs: styler
38+
39+
- name: Enable styler cache
40+
run: styler::cache_activate()
41+
shell: Rscript {0}
42+
43+
- name: Determine cache location
44+
id: styler-location
45+
run: |
46+
cat(
47+
"location=",
48+
styler::cache_info(format = "tabular")$location,
49+
"\n",
50+
file = Sys.getenv("GITHUB_OUTPUT"),
51+
append = TRUE,
52+
sep = ""
53+
)
54+
shell: Rscript {0}
55+
56+
- name: Cache styler
57+
uses: actions/cache@v3
58+
with:
59+
path: ${{ steps.styler-location.outputs.location }}
60+
key: ${{ runner.os }}-styler-${{ github.sha }}
61+
restore-keys: |
62+
${{ runner.os }}-styler-
63+
${{ runner.os }}-
64+
65+
- name: Style
66+
run: styler::style_pkg()
67+
shell: Rscript {0}
68+
69+
- name: Commit and push changes
70+
run: |
71+
if FILES_TO_COMMIT=($(git diff-index --name-only ${{ github.sha }} \
72+
| egrep --ignore-case '\.(R|[qR]md|Rmarkdown|Rnw|Rprofile)$'))
73+
then
74+
git config --local user.name "$GITHUB_ACTOR"
75+
git config --local user.email "[email protected]"
76+
git commit ${FILES_TO_COMMIT[*]} -m "Style code (GHA)"
77+
git pull --ff-only
78+
git push origin
79+
else
80+
echo "No changes to commit."
81+
fi

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Imports:
4848
Suggests:
4949
covidcast,
5050
data.table,
51-
epidatr,
51+
epidatr (>= 1.0.0),
5252
ggplot2,
5353
knitr,
5454
lubridate,

R/arx_classifier.R

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ arx_classifier <- function(
4747
predictors,
4848
trainer = parsnip::logistic_reg(),
4949
args_list = arx_class_args_list()) {
50-
51-
if (!is_classification(trainer))
50+
if (!is_classification(trainer)) {
5251
cli::cli_abort("`trainer` must be a {.pkg parsnip} model of mode 'classification'.")
52+
}
5353

5454
wf <- arx_class_epi_workflow(
5555
epi_data, outcome, predictors, trainer, args_list
@@ -65,13 +65,15 @@ arx_classifier <- function(
6565
tibble::as_tibble() %>%
6666
dplyr::select(-time_value)
6767

68-
structure(list(
69-
predictions = preds,
70-
epi_workflow = wf,
71-
metadata = list(
72-
training = attr(epi_data, "metadata"),
73-
forecast_created = Sys.time()
74-
)),
68+
structure(
69+
list(
70+
predictions = preds,
71+
epi_workflow = wf,
72+
metadata = list(
73+
training = attr(epi_data, "metadata"),
74+
forecast_created = Sys.time()
75+
)
76+
),
7577
class = c("arx_class", "canned_epipred")
7678
)
7779
}
@@ -117,12 +119,13 @@ arx_class_epi_workflow <- function(
117119
predictors,
118120
trainer = NULL,
119121
args_list = arx_class_args_list()) {
120-
121122
validate_forecaster_inputs(epi_data, outcome, predictors)
122-
if (!inherits(args_list, c("arx_class", "alist")))
123+
if (!inherits(args_list, c("arx_class", "alist"))) {
123124
rlang::abort("args_list was not created using `arx_class_args_list().")
124-
if (!(is.null(trainer) || is_classification(trainer)))
125+
}
126+
if (!(is.null(trainer) || is_classification(trainer))) {
125127
rlang::abort("`trainer` must be a `{parsnip}` model of mode 'classification'.")
128+
}
126129
lags <- arx_lags_validator(predictors, args_list$lags)
127130

128131
# --- preprocessor
@@ -172,8 +175,10 @@ arx_class_epi_workflow <- function(
172175
o2 <- rlang::sym(paste0("ahead_", args_list$ahead, "_", o))
173176
r <- r %>%
174177
step_epi_ahead(!!o, ahead = args_list$ahead, role = "pre-outcome") %>%
175-
step_mutate(outcome_class = cut(!!o2, breaks = args_list$breaks),
176-
role = "outcome") %>%
178+
step_mutate(
179+
outcome_class = cut(!!o2, breaks = args_list$breaks),
180+
role = "outcome"
181+
) %>%
177182
step_epi_naomit() %>%
178183
step_training_window(n_recent = args_list$n_training)
179184

@@ -245,9 +250,7 @@ arx_class_args_list <- function(
245250
method = c("rel_change", "linear_reg", "smooth_spline", "trend_filter"),
246251
log_scale = FALSE,
247252
additional_gr_args = list(),
248-
nafill_buffer = Inf
249-
) {
250-
253+
nafill_buffer = Inf) {
251254
.lags <- lags
252255
if (is.list(lags)) lags <- unlist(lags)
253256
method <- match.arg(method)
@@ -266,7 +269,8 @@ arx_class_args_list <- function(
266269
cli::cli_abort(
267270
c("`additional_gr_args` must be a {.cls list}.",
268271
"!" = "This is a {.cls {class(additional_gr_args)}}.",
269-
i = "See `?epiprocess::growth_rate` for available arguments.")
272+
i = "See `?epiprocess::growth_rate` for available arguments."
273+
)
270274
)
271275
}
272276

@@ -277,19 +281,20 @@ arx_class_args_list <- function(
277281

278282
max_lags <- max(lags)
279283
structure(
280-
enlist(lags = .lags,
281-
ahead,
282-
n_training,
283-
breaks,
284-
forecast_date,
285-
target_date,
286-
outcome_transform,
287-
max_lags,
288-
horizon,
289-
method,
290-
log_scale,
291-
additional_gr_args,
292-
nafill_buffer
284+
enlist(
285+
lags = .lags,
286+
ahead,
287+
n_training,
288+
breaks,
289+
forecast_date,
290+
target_date,
291+
outcome_transform,
292+
max_lags,
293+
horizon,
294+
method,
295+
log_scale,
296+
additional_gr_args,
297+
nafill_buffer
293298
),
294299
class = c("arx_class", "alist")
295300
)
@@ -300,4 +305,3 @@ print.arx_class <- function(x, ...) {
300305
name <- "ARX Classifier"
301306
NextMethod(name = name, ...)
302307
}
303-

0 commit comments

Comments
 (0)