Skip to content

Commit

Permalink
fixing check and linter
Browse files Browse the repository at this point in the history
  • Loading branch information
dsweber2 committed Aug 1, 2024
1 parent 13284f8 commit 6489d34
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
8 changes: 6 additions & 2 deletions R/revision_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#' actually change very much. Default is .1, or 10% of the final value
#' @param compactify_tol float, used if `drop_nas=TRUE`, it determines the
#' threshold for when two floats are considered identical.
#' @param should_compactify bool. Compactify if `TRUE`.
#' @examples
#'
#' revision_example <- revision_summary(archive_cases_dv_subset, percent_cli)
Expand All @@ -74,8 +75,8 @@ revision_summary <- function(epi_arch,
within_latest = 0.2,
quick_revision = as.difftime(3, units = "days"),
few_revisions = 3,
rel_spread_threshold = 0.1,
abs_spread_threshold = NULL,
rel_spread_threshold = 0.1,
compactify_tol = .Machine$double.eps^0.5,
should_compactify = TRUE) {
arg <- names(eval_select(rlang::expr(c(...)), allow_rename = FALSE, data = epi_arch$DT))
Expand Down Expand Up @@ -144,7 +145,10 @@ revision_summary <- function(epi_arch,
time_near_latest = as.difftime(time_to, units = "days") # nolint: object_usage_linter
) %>%
select(-time_to) %>%
relocate(time_value, geo_value, all_of(keys), n_revisions, min_lag, max_lag, time_near_latest, spread, rel_spread, min_value, max_value, median_value)
relocate(
time_value, geo_value, all_of(keys), n_revisions, min_lag, max_lag, # nolint: object_usage_linter
time_near_latest, spread, rel_spread, min_value, max_value, median_value # nolint: object_usage_linter
)
if (print_inform) {
cli_inform("Min lag (time to first version):")
difftime_summary(revision_behavior$min_lag) %>% print()
Expand Down
12 changes: 7 additions & 5 deletions man/revision_summary.Rd

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

13 changes: 13 additions & 0 deletions tests/testthat/_snaps/archive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# new_epi_archive correctly detects and warns about compactification

Code
res <- dumb_ex %>% as_epi_archive()
Condition
Warning:
Found rows that appear redundant based on last (version of each) observation carried forward; these rows have been removed to 'compactify' and save space:
Key: <geo_value, time_value, version>
geo_value time_value value version
<char> <Date> <num> <Date>
1: ca 2020-01-01 1 2020-01-02
Built-in `epi_archive` functionality should be unaffected, but results may change if you work directly with its fields (such as `DT`). See `?as_epi_archive` for details. To silence this warning but keep compactification, you can pass `compactify=TRUE` when constructing the archive.

0 comments on commit 6489d34

Please sign in to comment.