Skip to content

Commit

Permalink
style to fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
annakrystalli committed Aug 13, 2024
1 parent 8d8061d commit 4aa5ca2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 27 deletions.
6 changes: 5 additions & 1 deletion R/check_tbl_spl_compound_taskid_set.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ check_tbl_spl_compound_taskid_set <- function(tbl, round_id, file_path, hub_path
details = compile_msg(compound_taskid_set),
errors = compile_errors(compound_taskid_set),
error = TRUE,
compound_taskid_set = if (check) { compound_taskid_set } else { NA }
compound_taskid_set = if (check) {
compound_taskid_set
} else {
NA
}
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/v3-sample-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spl_hash_tbl <- function(tbl, round_id, config_tasks, compound_taskid_set = NULL
)
) %>%
purrr::compact() %>%
purrr::imap( ~ dplyr::mutate(.x, mt_id = as.integer(.y))) %>% # add mt_id
purrr::imap(~dplyr::mutate(.x, mt_id = as.integer(.y))) %>% # add mt_id
purrr::list_rbind()
}

Expand Down
22 changes: 11 additions & 11 deletions tests/testthat/test-check_tbl_spl_compound_taskid_set.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ test_that("Different compound_taskid_sets work", {
# Mock the config file to include all task ids a derived task id depends on
# in the compound_taskid_set but exclude the derived task id itself.
# Currently will fail
config_tasks_full_ctids <- purrr::modify_in(
hubUtils::read_config_file(
fs::path(hub_path, "hub-config", "tasks.json")
),
list(
"rounds", 1, "model_tasks", 2,
"output_type", "sample",
"output_type_id_params", "compound_taskid_set"
),
~ c("reference_date", "horizon", "location", "variant")
)
config_tasks_full_ctids <- purrr::modify_in(
hubUtils::read_config_file(
fs::path(hub_path, "hub-config", "tasks.json")
),
list(
"rounds", 1, "model_tasks", 2,
"output_type", "sample",
"output_type_id_params", "compound_taskid_set"
),
~ c("reference_date", "horizon", "location", "variant")
)

mockery::stub(
check_tbl_spl_compound_taskid_set,
Expand Down
13 changes: 7 additions & 6 deletions tests/testthat/test-check_tbl_spl_compound_tid.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ test_that("Overriding compound_taskid_set in check_tbl_spl_compound_tid works",
c("reference_date", "horizon")
)
tbl_coarse <- create_spl_file("2022-10-22",
compound_taskid_set = compound_taskid_set,
write = FALSE,
out_datatype = "chr",
n_samples = 1L
compound_taskid_set = compound_taskid_set,
write = FALSE,
out_datatype = "chr",
n_samples = 1L
)


Expand All @@ -65,9 +65,10 @@ test_that("Overriding compound_taskid_set in check_tbl_spl_compound_tid works",
)
)

# Validation providing coarser compound taskid set succeeds
# Validation providing coarser compound taskid set succeeds
expect_snapshot(
check_tbl_spl_compound_tid(tbl_coarse, round_id, file_path, hub_path,
compound_taskid_set = compound_taskid_set)
compound_taskid_set = compound_taskid_set
)
)
})
14 changes: 7 additions & 7 deletions tests/testthat/test-check_tbl_spl_n.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ test_that("Overriding compound_taskid_set in check_tbl_spl_compound_tid works",
c("reference_date", "horizon")
)
tbl_coarse <- create_spl_file("2022-10-22",
compound_taskid_set = compound_taskid_set,
write = FALSE,
out_datatype = "chr",
n_samples = 1L
compound_taskid_set = compound_taskid_set,
write = FALSE,
out_datatype = "chr",
n_samples = 1L
)

# Validation of coarser files should return check failure.
Expand All @@ -104,9 +104,9 @@ test_that("Overriding compound_taskid_set in check_tbl_spl_compound_tid works",

# Create 100 spls of each compound idx
tbl_full <- create_spl_file("2022-10-22",
compound_taskid_set = compound_taskid_set,
write = FALSE,
out_datatype = "chr"
compound_taskid_set = compound_taskid_set,
write = FALSE,
out_datatype = "chr"
)

# This succeeds!
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-check_tbl_spl_non_compound_tid.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ test_that("Overriding compound_taskid_set in check_tbl_spl_compound_tid works",
# also succeeds.
expect_snapshot(
check_tbl_spl_non_compound_tid(tbl_coarse, round_id, file_path, hub_path,
compound_taskid_set = compound_taskid_set)
compound_taskid_set = compound_taskid_set
)
)
})

0 comments on commit 4aa5ca2

Please sign in to comment.