Skip to content

Commit 91f6654

Browse files
authored
Merge pull request #644 from cmu-delphi/ds/is_archive
feat: add is_epi_archive
2 parents f809f0e + 25a1d52 commit 91f6654

File tree

4 files changed

+81
-35
lines changed

4 files changed

+81
-35
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export(group_modify)
8686
export(growth_rate)
8787
export(growth_rate_params)
8888
export(guess_period)
89+
export(is_epi_archive)
8990
export(is_epi_df)
9091
export(is_grouped_epi_archive)
9192
export(key_colnames)

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.x.y will indicate PR's.
44

5+
# epiprocess 0.12
6+
7+
## New features
8+
9+
- `is_epi_archive` function has been reintroduced.
10+
511
# epiprocess 0.11
612

713
## Breaking changes

R/archive.R

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,12 @@ next_after.Date <- function(x) x + 1L
230230
#' value of `clobberable_versions_start` does not fully trust these empty
231231
#' updates, and assumes that any version `>= max(x$version)` could be
232232
#' clobbered.) If `nrow(x) == 0`, then this argument is mandatory.
233-
#' @return An `epi_archive` object.
233+
#' @return * Of `new_epi_archive`: an (unvalidated) `epi_archive`
234234
#'
235235
#' @seealso [`epix_as_of`] [`epix_merge`] [`epix_slide`]
236236
#' @importFrom dplyr if_any if_all everything
237237
#' @importFrom utils capture.output
238238
#'
239-
#' @name epi_archive
240-
#' @export
241-
#'
242239
#' @examples
243240
#' # Simple ex. with necessary keys
244241
#' tib <- tibble::tibble(
@@ -277,6 +274,9 @@ next_after.Date <- function(x) x + 1L
277274
#'
278275
#' x <- df %>% as_epi_archive(other_keys = "county")
279276
#'
277+
#' @name epi_archive
278+
#' @order 3
279+
#' @export
280280
new_epi_archive <- function(
281281
x,
282282
geo_type,
@@ -329,7 +329,11 @@ new_epi_archive <- function(
329329

330330
#' Perform second (costly) round of validation that `x` is a proper `epi_archive`
331331
#'
332+
#' @return * Of `validate_epi_archive`: an `epi_archive`,
333+
#' [invisibly][base::invisible] (or raises an error if `x` was invalid)
334+
#'
332335
#' @rdname epi_archive
336+
#' @order 4
333337
#' @export
334338
validate_epi_archive <- function(x) {
335339
assert_class(x, "epi_archive")
@@ -515,8 +519,10 @@ is_locf <- function(vec, abs_tol, is_key) { # nolint: object_usage_linter
515519
#' @param .versions_end location based versions_end, used to avoid prefix
516520
#' `version = issue` from being assigned to `versions_end` instead of being
517521
#' used to rename columns.
522+
#' @return * Of `as_epi_archive`: an `epi_archive` object
518523
#'
519524
#' @rdname epi_archive
525+
#' @order 1
520526
#'
521527
#' @export
522528
as_epi_archive <- function(
@@ -808,3 +814,16 @@ clone.epi_archive <- function(x) {
808814
x$DT <- data.table::copy(x$DT)
809815
x
810816
}
817+
818+
#' Test for `epi_archive` format
819+
#'
820+
#' @param x An object.
821+
#' @return * Of `is_epi_archive`: `TRUE` if the object inherits from `epi_archive`,
822+
#' otherwise `FALSE`.
823+
#'
824+
#' @rdname epi_archive
825+
#' @order 2
826+
#' @export
827+
is_epi_archive <- function(x) {
828+
inherits(x, "epi_archive")
829+
}

man/epi_archive.Rd

Lines changed: 51 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)