Skip to content

wip feat: replace R6 epi_archive with S3 implementation #431

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

Merged
merged 18 commits into from
May 3, 2024
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
new_archive validation tightening, streamlining, type stability
- Forbid `NA` `compactify`
- Remove `missing` checks when `is.null` suffices
- Remove redundant default code
- Make local `other_keys` have more consistent typing across branches
  • Loading branch information
brookslogan authored and dshemetov committed Apr 30, 2024
commit 183d0f1230f643ee1c355ee24b4c27e3de65a798
16 changes: 5 additions & 11 deletions R/archive.R
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@ new_epi_archive <- function(
}

# If time type is missing, then try to guess it
if (missing(time_type) || is.null(time_type)) {
if (is.null(time_type)) {
time_type <- guess_time_type(x$time_value)
}

# Finish off with small checks on keys variables and metadata
if (missing(other_keys)) other_keys <- NULL
if (missing(additional_metadata) || is.null(additional_metadata)) additional_metadata <- list()
if (is.null(other_keys)) other_keys <- character(0L)
if (is.null(additional_metadata)) additional_metadata <- list()
if (!test_subset(other_keys, names(x))) {
cli_abort("`other_keys` must be contained in the column names of `x`.")
}
Expand All @@ -325,17 +325,11 @@ new_epi_archive <- function(
}

# Conduct checks and apply defaults for `compactify`
if (missing(compactify)) {
compactify <- NULL
}
assert_logical(compactify, len = 1, null.ok = TRUE)
assert_logical(compactify, len = 1, any.missing = FALSE, null.ok = TRUE)

# Apply defaults and conduct checks for
# `clobberable_versions_start`, `versions_end`:
if (missing(clobberable_versions_start)) {
clobberable_versions_start <- NA
}
if (missing(versions_end) || is.null(versions_end)) {
if (is.null(versions_end)) {
versions_end <- max_version_with_row_in(x)
}
validate_version_bound(clobberable_versions_start, x, na_ok = TRUE)
Expand Down