Skip to content

Commit 155ea73

Browse files
committed
Rename observed_versions_end[_conflict] -> versions_end[_conflict]
1 parent 8271a97 commit 155ea73

12 files changed

+124
-124
lines changed

R/archive.R

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#' Validate a version bound arg
1010
#'
11-
#' Expected to be used on `clobberable_versions_start`, `observed_versions_end`,
11+
#' Expected to be used on `clobberable_versions_start`, `versions_end`,
1212
#' and similar arguments. Some additional context-specific checks may be needed.
1313
#'
1414
#' @param version_bound the version bound to validate
@@ -73,7 +73,7 @@ validate_version_bound = function(version_bound, x, na_ok,
7373
#' @export
7474
max_version_with_row_in = function(x) {
7575
if (nrow(x) == 0L) {
76-
Abort(sprintf("`nrow(x)==0L`, representing a data set history with no row up through the latest observed version, but we don't have a sensible guess at what version that is, or whether any of the empty versions might be clobbered in the future; if we use `x` to form an `epi_archive`, then `clobberable_versions_start` and `observed_versions_end` must be manually specified."),
76+
Abort(sprintf("`nrow(x)==0L`, representing a data set history with no row up through the latest observed version, but we don't have a sensible guess at what version that is, or whether any of the empty versions might be clobbered in the future; if we use `x` to form an `epi_archive`, then `clobberable_versions_start` and `versions_end` must be manually specified."),
7777
class="epiprocess__max_version_cannot_be_used")
7878
} else {
7979
version_col = purrr::pluck(x, "version") # error not NULL if doesn't exist
@@ -130,7 +130,7 @@ next_after.Date = function(x) x + 1L
130130
#'
131131
#' In general, the last version of each observation is carried forward (LOCF) to
132132
#' fill in data between recorded versions, and between the last recorded
133-
#' update and the `observed_versions_end`. One consequence is that the `DT`
133+
#' update and the `versions_end`. One consequence is that the `DT`
134134
#' doesn't have to contain a full snapshot of every version (although this
135135
#' generally works), but can instead contain only the rows that are new or
136136
#' changed from the previous version (see `compactify`, which does this
@@ -211,7 +211,7 @@ epi_archive =
211211
time_type = NULL,
212212
additional_metadata = NULL,
213213
clobberable_versions_start = NULL,
214-
observed_versions_end = NULL,
214+
versions_end = NULL,
215215
#' @description Creates a new `epi_archive` object.
216216
#' @param x A data frame, data table, or tibble, with columns `geo_value`,
217217
#' `time_value`, `version`, and then any additional number of columns.
@@ -233,7 +233,7 @@ epi_archive =
233233
#' carried forward (LOCF) to interpolate between the version data provided,
234234
#' rows that don't change these LOCF results can potentially be omitted to
235235
#' save space while maintaining the same behavior (with the help of the
236-
#' `clobberable_versions_start` and `observed_versions_end` fields in some
236+
#' `clobberable_versions_start` and `versions_end` fields in some
237237
#' edge cases). `TRUE` will remove these rows, `FALSE` will not, and missing
238238
#' or `NULL` will remove these rows and issue a warning. Generally, this can
239239
#' be set to `TRUE`, but if you directly inspect or edit the fields of the
@@ -243,7 +243,7 @@ epi_archive =
243243
#' potential for space, time, or bandwidth savings upstream the data pipeline,
244244
#' e.g., when fetching, storing, or preparing the input data `x`
245245
#' @param clobberable_versions_start Optional; as in [`as_epi_archive`]
246-
#' @param observed_versions_end Optiona; as in [`as_epi_archive`]
246+
#' @param versions_end Optional; as in [`as_epi_archive`]
247247
#' @return An `epi_archive` object.
248248
#' @importFrom data.table as.data.table key setkeyv
249249
#'
@@ -252,7 +252,7 @@ epi_archive =
252252
#' and examples of parameter names.
253253
initialize = function(x, geo_type, time_type, other_keys,
254254
additional_metadata, compactify,
255-
clobberable_versions_start, observed_versions_end) {
255+
clobberable_versions_start, versions_end) {
256256
# Check that we have a data frame
257257
if (!is.data.frame(x)) {
258258
Abort("`x` must be a data frame.")
@@ -306,26 +306,26 @@ epi_archive =
306306
}
307307

308308
# Apply defaults and conduct checks and apply defaults for
309-
# `clobberable_versions_start`, `observed_versions_end`:
309+
# `clobberable_versions_start`, `versions_end`:
310310
if (missing(clobberable_versions_start)) {
311311
clobberable_versions_start <- max_version_with_row_in(x)
312312
}
313-
if (missing(observed_versions_end)) {
314-
observed_versions_end <- max_version_with_row_in(x)
313+
if (missing(versions_end)) {
314+
versions_end <- max_version_with_row_in(x)
315315
}
316316
validate_version_bound(clobberable_versions_start, x, na_ok=TRUE)
317-
validate_version_bound(observed_versions_end, x, na_ok=FALSE)
318-
if (nrow(x) > 0L && observed_versions_end < max(x[["version"]])) {
319-
Abort(sprintf("`observed_versions_end` was %s, but `x` contained
317+
validate_version_bound(versions_end, x, na_ok=FALSE)
318+
if (nrow(x) > 0L && versions_end < max(x[["version"]])) {
319+
Abort(sprintf("`versions_end` was %s, but `x` contained
320320
updates for a later version or versions, up through %s",
321-
observed_versions_end, max(x[["version"]])),
322-
class="epiprocess__observed_versions_end_earlier_than_updates")
321+
versions_end, max(x[["version"]])),
322+
class="epiprocess__versions_end_earlier_than_updates")
323323
}
324-
if (!is.na(clobberable_versions_start) && clobberable_versions_start > observed_versions_end) {
325-
Abort(sprintf("`observed_versions_end` was %s, but a `clobberable_versions_start`
324+
if (!is.na(clobberable_versions_start) && clobberable_versions_start > versions_end) {
325+
Abort(sprintf("`versions_end` was %s, but a `clobberable_versions_start`
326326
of %s indicated that there were later observed versions",
327-
observed_versions_end, clobberable_versions_start),
328-
class="epiprocess__observed_versions_end_earlier_than_clobberable_versions_start")
327+
versions_end, clobberable_versions_start),
328+
class="epiprocess__versions_end_earlier_than_clobberable_versions_start")
329329
}
330330

331331
# --- End of validation and replacing missing args with defaults ---
@@ -395,7 +395,7 @@ epi_archive =
395395
self$time_type = time_type
396396
self$additional_metadata = additional_metadata
397397
self$clobberable_versions_start = clobberable_versions_start
398-
self$observed_versions_end = observed_versions_end
398+
self$versions_end = versions_end
399399
},
400400
print = function() {
401401
cat("An `epi_archive` object, with metadata:\n")
@@ -421,8 +421,8 @@ epi_archive =
421421
cat(sprintf("* %-14s = %s\n", "clobberable versions start",
422422
self$clobberable_versions_start))
423423
}
424-
cat(sprintf("* %-14s = %s\n", "observed versions end",
425-
self$observed_versions_end))
424+
cat(sprintf("* %-14s = %s\n", "versions end",
425+
self$versions_end))
426426
cat("----------\n")
427427
cat(sprintf("Data archive (stored in DT field): %i x %i\n",
428428
nrow(self$DT), ncol(self$DT)))
@@ -458,8 +458,8 @@ epi_archive =
458458
if (is.na(max_version)) {
459459
Abort("`max_version` must not be NA.")
460460
}
461-
if (max_version > self$observed_versions_end) {
462-
Abort("`max_version` must be at most `self$observed_versions_end`.")
461+
if (max_version > self$versions_end) {
462+
Abort("`max_version` must be at most `self$versions_end`.")
463463
}
464464
if (!is.na(self$clobberable_versions_start) && max_version >= self$clobberable_versions_start) {
465465
Warn('Getting data as of some "clobberable" version that might be hotfixed, synced, or otherwise replaced later with different data using the same version tag. Thus, the snapshot that we produce here might not be reproducible later. See `?epi_archive` for more info and `?epix_as_of` on how to muffle.',
@@ -497,7 +497,7 @@ epi_archive =
497497
how=c("na", "locf")) {
498498
validate_version_bound(fill_versions_end, self$DT, na_ok=FALSE)
499499
how <- arg_match(how)
500-
if (self$observed_versions_end < fill_versions_end) {
500+
if (self$versions_end < fill_versions_end) {
501501
new_DT = switch(
502502
how,
503503
"na" = {
@@ -507,15 +507,15 @@ epi_archive =
507507
# added if `self` is outdated.
508508
nonversion_key_cols = setdiff(key(self$DT), "version")
509509
nonkey_cols = setdiff(names(self$DT), key(self$DT))
510-
next_version_tag = next_after(self$observed_versions_end)
510+
next_version_tag = next_after(self$versions_end)
511511
if (next_version_tag > fill_versions_end) {
512512
Abort(sprintf(paste(
513513
"Apparent problem with `next_after` implementation:",
514514
"archive contained observations through version %s",
515515
"and the next possible version was supposed to be %s,",
516516
"but this appeared to jump from a version < %3$s",
517517
"to one > %3$s, implying at least one version in between."
518-
), self$observed_versions_end, next_version_tag, fill_versions_end))
518+
), self$versions_end, next_version_tag, fill_versions_end))
519519
}
520520
nonversion_key_vals_ever_recorded = unique(self$DT, by=nonversion_key_cols)
521521
# In edge cases, the `unique` result can alias the original
@@ -537,11 +537,11 @@ epi_archive =
537537
self$DT
538538
}
539539
)
540-
new_observed_versions_end = fill_versions_end
540+
new_versions_end = fill_versions_end
541541
# Update `self` all at once with simple, error-free operations +
542542
# return below:
543543
self$DT <- new_DT
544-
self$observed_versions_end <- new_observed_versions_end
544+
self$versions_end <- new_versions_end
545545
} else {
546546
# Already sufficiently up to date; nothing to do.
547547
}
@@ -555,11 +555,11 @@ epi_archive =
555555
#' of the non-R6-method version, which does not mutate either archive, and
556556
#' does not alias either archive's `DT`.
557557
#' @param y as in [`epix_merge`]
558-
#' @param observed_versions_end_conflict as in [`epix_merge`]
558+
#' @param versions_end_conflict as in [`epix_merge`]
559559
#' @param compactify as in [`epix_merge`]
560-
merge = function(y, observed_versions_end_conflict = c("stop","na","locf","truncate"), compactify=TRUE) {
560+
merge = function(y, versions_end_conflict = c("stop","na","locf","truncate"), compactify=TRUE) {
561561
result = epix_merge(self, y,
562-
observed_versions_end_conflict = observed_versions_end_conflict,
562+
versions_end_conflict = versions_end_conflict,
563563
compactify = compactify)
564564

565565
if (length(epi_archive$private_fields) != 0L) {
@@ -775,7 +775,7 @@ epi_archive =
775775
#' redundant) is present with version `ver`, then all previous versions must
776776
#' be finalized and non-clobberable, although `ver` (and onward) might still
777777
#' be modified, (ii) even if we have "observed" empty updates for some
778-
#' versions beyond `max(x$version)` (as indicated by `observed_versions_end`;
778+
#' versions beyond `max(x$version)` (as indicated by `versions_end`;
779779
#' see below), we can't assume `max(x$version)` has been finalized, because we
780780
#' might see a nonfinalized version + empty subsequent versions due to
781781
#' upstream database replication delays in combination with the upstream
@@ -784,7 +784,7 @@ epi_archive =
784784
#' `compactify` are not redundant, and actually come from an explicit version
785785
#' release that indicates that preceding versions are finalized. If `nrow(x)
786786
#' == 0`, then this argument is mandatory.
787-
#' @param observed_versions_end Optional; length-1, same `class` and `typeof` as
787+
#' @param versions_end Optional; length-1, same `class` and `typeof` as
788788
#' `x$version`: what is the last version we have observed? The default is
789789
#' `max_version_with_row_in(x)`, but values greater than this could also be
790790
#' valid, and would indicate that we observed additional versions of the data
@@ -841,9 +841,9 @@ as_epi_archive = function(x, geo_type, time_type, other_keys,
841841
additional_metadata = list(),
842842
compactify = NULL,
843843
clobberable_versions_start = max_version_with_row_in(x),
844-
observed_versions_end = max_version_with_row_in(x)) {
844+
versions_end = max_version_with_row_in(x)) {
845845
epi_archive$new(x, geo_type, time_type, other_keys, additional_metadata,
846-
compactify, clobberable_versions_start, observed_versions_end)
846+
compactify, clobberable_versions_start, versions_end)
847847
}
848848

849849
#' Test for `epi_archive` format

0 commit comments

Comments
 (0)