Skip to content

Commit

Permalink
style: styler (GHA)
Browse files Browse the repository at this point in the history
  • Loading branch information
brookslogan committed Oct 18, 2024
1 parent 839e921 commit 592c3a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
8 changes: 5 additions & 3 deletions R/key_colnames.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ key_colnames.data.frame <- function(x, ...,
assert_character(time_keys)
assert_character(other_keys)
assert_character(exclude)
keys = c(geo_keys, other_keys, time_keys)
keys <- c(geo_keys, other_keys, time_keys)
if (!all(keys %in% names(x))) {
cli_abort(c(
"Some of the specified key columns aren't present in `x`",
Expand All @@ -67,11 +67,13 @@ key_colnames.epi_df <- function(x, ...,
check_dots_empty0(...)
if (!identical(geo_keys, "geo_value")) {
cli_abort('If `x` is an `epi_df`, then `geo_keys` must be `"geo_value"`',
class = "epiprocess__key_colnames__mismatched_geo_keys")
class = "epiprocess__key_colnames__mismatched_geo_keys"
)
}
if (!identical(time_keys, "time_value")) {
cli_abort('If `x` is an `epi_df`, then `time_keys` must be `"time_value"`',
class = "epiprocess__key_colnames__mismatched_time_keys")
class = "epiprocess__key_colnames__mismatched_time_keys"
)
}
expected_other_keys <- attr(x, "metadata")$other_keys
if (is.null(other_keys)) {
Expand Down
8 changes: 0 additions & 8 deletions tests/testthat/test-key_colnames.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
test_that("`key_colnames` on non-`epi_df`-like tibbles works as expected", {

k1k2_tbl <- tibble::tibble(k1 = 1, k2 = 1)

expect_equal(
Expand Down Expand Up @@ -35,11 +34,9 @@ test_that("`key_colnames` on non-`epi_df`-like tibbles works as expected", {
key_colnames(k1k2_tbl, geo_keys = c("k1", "k2"), other_keys = character(0L)),
c("k1", "k2")
)

})

test_that("`key_colnames` on `epi_df`s and similar tibbles works as expected", {

gat_tbl <- tibble::tibble(geo_value = 1, age_group = 1, time_value = 1)
gat_edf <- as_epi_df(gat_tbl, other_keys = "age_group", as_of = 2)

Expand Down Expand Up @@ -103,11 +100,9 @@ test_that("`key_colnames` on `epi_df`s and similar tibbles works as expected", {
key_colnames(gat_edf, exclude = c("geo_value", "time_value")),
c("age_group")
)

})

test_that("`key_colnames` on tsibbles works as expected", {

k1k2i_tsbl <- tsibble::tsibble(k1 = 1, k2 = 1, i = 1, key = c(k1, k2), index = i)

# Normal operation:
Expand All @@ -133,11 +128,9 @@ test_that("`key_colnames` on tsibbles works as expected", {
key_colnames(k1k2i_tsbl %>% tsibble::index_by(fake_coarser_i = i)),
class = "epiprocess__key_colnames__incomplete_reindexing_operation"
)

})

test_that("`key_colnames` on `epi_archive`s works as expected", {

gatv_ea <- tibble(geo_value = 1, age_group = 1, time_value = 1, version = 2) %>%
as_epi_archive(other_keys = "age_group")

Expand Down Expand Up @@ -168,5 +161,4 @@ test_that("`key_colnames` on `epi_archive`s works as expected", {
key_colnames(gatv_ea, exclude = c("version", "time_value")),
c("geo_value", "age_group")
)

})

0 comments on commit 592c3a2

Please sign in to comment.