Skip to content

Commit f45f30e

Browse files
committed
refactor: changes from review
* remove is_epi_archive and delete in epix_slide * simplify group_by_drop_default * filter and move library calls to testthat.R
1 parent 5ea168e commit f45f30e

15 files changed

+8
-95
lines changed

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export(filter)
6464
export(group_by)
6565
export(group_modify)
6666
export(growth_rate)
67-
export(is_epi_archive)
6867
export(is_epi_df)
6968
export(is_grouped_epi_archive)
7069
export(key_colnames)
@@ -94,6 +93,7 @@ importFrom(checkmate,checkInt)
9493
importFrom(checkmate,check_atomic)
9594
importFrom(checkmate,check_data_frame)
9695
importFrom(checkmate,check_names)
96+
importFrom(checkmate,expect_class)
9797
importFrom(checkmate,test_set_equal)
9898
importFrom(checkmate,test_subset)
9999
importFrom(checkmate,vname)

R/archive.R

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -652,31 +652,6 @@ group_by.epi_archive <- function(.data, ..., .add = FALSE, .drop = dplyr::group_
652652
}
653653

654654

655-
#' Test for `epi_archive` format
656-
#'
657-
#' @param x An object.
658-
#' @param grouped_okay Optional; Boolean; should a `grouped_epi_archive` also
659-
#' count? Default is `FALSE`.
660-
#' @return `TRUE` if the object inherits from `epi_archive`.
661-
#'
662-
#' @export
663-
#' @examples
664-
#' is_epi_archive(jhu_csse_daily_subset) # FALSE (this is an epi_df, not epi_archive)
665-
#' is_epi_archive(archive_cases_dv_subset) # TRUE
666-
#'
667-
#' # By default, grouped_epi_archives don't count as epi_archives, as they may
668-
#' # support a different set of operations from regular `epi_archives`. This
669-
#' # behavior can be controlled by `grouped_okay`.
670-
#' grouped_archive <- archive_cases_dv_subset %>% group_by(geo_value)
671-
#' is_epi_archive(grouped_archive) # FALSE
672-
#' is_epi_archive(grouped_archive, grouped_okay = TRUE) # TRUE
673-
#'
674-
#' @seealso [`is_grouped_epi_archive`]
675-
is_epi_archive <- function(x, grouped_okay = FALSE) {
676-
inherits(x, "epi_archive") || grouped_okay && inherits(x, "grouped_epi_archive")
677-
}
678-
679-
680655
#' Clone an `epi_archive` object.
681656
#'
682657
#' @param x An `epi_archive` object.

R/epiprocess.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#' @importFrom checkmate assert assert_scalar assert_data_frame anyMissing
88
#' assert_logical assert_list assert_character assert_class
99
#' assert_int assert_numeric check_data_frame vname check_atomic
10-
#' anyInfinite test_subset test_set_equal checkInt
10+
#' anyInfinite test_subset test_set_equal checkInt expect_class
1111
#' @importFrom cli cli_abort cli_warn
1212
#' @importFrom rlang %||%
1313
#' @name epiprocess

R/grouped_epi_archive.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ group_by.grouped_epi_archive <- function(
157157
#'
158158
#' @export
159159
group_by_drop_default.grouped_epi_archive <- function(.tbl) {
160-
x <- .tbl
161-
x$private$drop
160+
.tbl$private$drop
162161
}
163162

164163

R/methods-epi_archive.R

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -797,9 +797,6 @@ epix_slide <- function(
797797
as_list_col = FALSE,
798798
names_sep = "_",
799799
all_versions = FALSE) {
800-
if (!is_epi_archive(x, grouped_okay = TRUE)) {
801-
cli_abort("`x` must be of class `epi_archive` or `grouped_epi_archive`.")
802-
}
803800
UseMethod("epix_slide")
804801
}
805802

man/is_epi_archive.Rd

Lines changed: 0 additions & 35 deletions
This file was deleted.

tests/testthat.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
library(testthat)
22
library(epiprocess)
33

4+
library(dplyr)
5+
46
test_check("epiprocess")

tests/testthat/test-archive.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
library(dplyr)
2-
31
test_that("first input must be a data.frame", {
42
expect_error(as_epi_archive(c(1, 2, 3), compactify = FALSE),
53
regexp = "Must be of type 'data.frame'."

tests/testthat/test-autoplot.R

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
library(dplyr)
2-
31
d <- as.Date("2020-01-01")
4-
52
raw_df_chr <- dplyr::bind_rows(
63
dplyr::tibble(geo_value = "ak", time_value = d + 1:5, value = "a"),
74
dplyr::tibble(geo_value = "al", time_value = d + 1:5, value = "d")

tests/testthat/test-compactify.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
library(epiprocess)
2-
library(data.table)
3-
library(dplyr)
4-
51
dt <- archive_cases_dv_subset$DT
62
dt <- filter(dt, geo_value == "ca") %>%
73
filter(version <= "2020-06-15") %>%

0 commit comments

Comments
 (0)