From 98c881d8e04675599cbf44d0ea3386e968e466eb Mon Sep 17 00:00:00 2001 From: Chris Orwa Date: Tue, 22 Oct 2024 10:42:19 +0300 Subject: [PATCH] reduce tests --- tests/testthat/_snaps/est.incidence.by.md | 25 ------ tests/testthat/_snaps/est.incidence.by.new.md | 30 ------- tests/testthat/test-est.incidence.by.R | 87 ------------------- 3 files changed, 142 deletions(-) delete mode 100644 tests/testthat/_snaps/est.incidence.by.md delete mode 100644 tests/testthat/_snaps/est.incidence.by.new.md diff --git a/tests/testthat/_snaps/est.incidence.by.md b/tests/testthat/_snaps/est.incidence.by.md deleted file mode 100644 index e77fb829..00000000 --- a/tests/testthat/_snaps/est.incidence.by.md +++ /dev/null @@ -1,25 +0,0 @@ -# est.incidence.by() produces expected results for typhoid data - - Code - typhoid_results - Output - `seroincidence.by` object estimated given the following setup: - a) Antigen isotypes : HlyE_IgG, HlyE_IgA - b) Strata : Country - - This object is a list of `seroincidence` objects, with added meta-data attributes:`antigen_isos` - Character vector of antigen isotypes used in analysis. - `Strata` - Input parameter strata of function `est.incidence.by()` - - Call the `summary()` function to obtain output results. - ---- - - structure(list("Stratum 1" = structure(list(minimum = 260.546868067556, - estimate = -2.02114708582914, gradient = 3.37492026736821e-07, - hessian = structure(37.570481481294, dim = c(1L, 1L)), code = 1L, - iterations = 4L), class = c("seroincidence", "list"), lambda_start = 0.1, antigen_isos = c("HlyE_IgG", - "HlyE_IgA"))), antigen_isos = c("HlyE_IgG", "HlyE_IgA"), Strata = structure(list( - Stratum = "Stratum 1", Country = "Pakistan", n = 50L), row.names = c(NA, - -1L), class = c("tbl_df", "tbl", "data.frame"), strata_vars = "Country"), graphs_included = FALSE, class = c("seroincidence.by", - "list")) - diff --git a/tests/testthat/_snaps/est.incidence.by.new.md b/tests/testthat/_snaps/est.incidence.by.new.md deleted file mode 100644 index 375c2981..00000000 --- a/tests/testthat/_snaps/est.incidence.by.new.md +++ /dev/null @@ -1,30 +0,0 @@ -# est.incidence.by() produces expected results for typhoid data - - Code - typhoid_results - Output - `seroincidence.by` object estimated given the following setup: - a) Antigen isotypes : HlyE_IgG, HlyE_IgA - b) Strata : catchment - - This object is a list of `seroincidence` objects, with added meta-data attributes:`antigen_isos` - Character vector of antigen isotypes used in analysis. - `Strata` - Input parameter strata of function `est.incidence.by()` - - Call the `summary()` function to obtain output results. - ---- - - structure(list("Stratum 1" = structure(list(minimum = 111.463434776159, - estimate = -2.41983536033088, gradient = -3.74675296382939e-06, - hessian = structure(15.251407603436, dim = c(1L, 1L)), code = 1L, - iterations = 4L), class = c("seroincidence", "list"), lambda_start = 0.1, antigen_isos = c("HlyE_IgG", - "HlyE_IgA")), "Stratum 2" = structure(list(minimum = 146.290052920951, - estimate = -1.640278556419, gradient = -8.66368377467952e-08, - hessian = structure(21.109488557163, dim = c(1L, 1L)), code = 1L, - iterations = 5L), class = c("seroincidence", "list"), lambda_start = 0.1, antigen_isos = c("HlyE_IgG", - "HlyE_IgA"))), antigen_isos = c("HlyE_IgG", "HlyE_IgA"), Strata = structure(list( - Stratum = c("Stratum 1", "Stratum 2"), catchment = c("aku", - "kgh"), n = c(25L, 25L)), row.names = c(NA, -2L), class = c("tbl_df", - "tbl", "data.frame"), strata_vars = "catchment"), graphs_included = FALSE, class = c("seroincidence.by", - "list")) - diff --git a/tests/testthat/test-est.incidence.by.R b/tests/testthat/test-est.incidence.by.R index efa0197f..e5ce435f 100644 --- a/tests/testthat/test-est.incidence.by.R +++ b/tests/testthat/test-est.incidence.by.R @@ -1,90 +1,3 @@ -test_that( - "est.incidence.by() produces expected results for typhoid data", - { - library(dplyr) - # get pop data - xs_data <- load_pop_data( - file_path = "https://osf.io/download//n6cp3/", - age = "Age", - value = "result", - id = "index_id", - standardize = TRUE - ) %>% - filter(Country == "Pakistan") %>% - slice_head(n = 100) - - # get noise data - noise <- load_noise_params("https://osf.io/download//hqy4v/") %>% - filter(Country == "Pakistan") - - # get curve data - curve <- load_curve_params("https://osf.io/download/rtw5k/") # slice if test is too slow (.by = antigen_iso)) - - # set start - start <- .05 - - typhoid_results <- est.incidence.by( - strata = c("catchment"), - pop_data = xs_data, - curve_param = curve, - curve_strata_varnames = "catchment", - noise_strata_varnames = "catchment", - noise_param = noise, - antigen_isos = c("HlyE_IgG", "HlyE_IgA"), - num_cores = 8 # Allow for parallel processing to decrease run time - ) - - expect_snapshot(x = typhoid_results) - - expect_snapshot_value(typhoid_results, style = "deparse") - } -) - -test_that("`est.incidence.by()` produces expected results", { - curves <- load_curve_params("https://osf.io/download/rtw5k/") - noise <- load_noise_params("https://osf.io/download//hqy4v/") - xs_data_true <- load_pop_data( - file_path = "https://osf.io/download//n6cp3/", - age = "Age", - value = "result", - id = "index_id", - standardize = TRUE - ) %>% - filter(Country == "Pakistan") %>% - slice_head(n = 100) - - - est_true <- est.incidence.by( - strata = c("catchment"), - pop_data = xs_data_true, - curve_params = curves, - noise_params = noise %>% filter(Country == "Pakistan"), - antigen_isos = c("HlyE_IgG", "HlyE_IgA"), - num_cores = 8 # Allow for parallel processing to decrease run time - ) - - xs_data_false <- load_pop_data( - file_path = "https://osf.io/download//n6cp3/", - age = "Age", - value = "result", - id = "index_id", - standardize = FALSE - ) %>% - filter(Country == "Pakistan") %>% - slice_head(n = 100) - - - est_false <- est.incidence.by( - strata = c("catchment"), - pop_data = xs_data_false, - curve_params = curves, - noise_params = noise %>% filter(Country == "Pakistan"), - antigen_isos = c("HlyE_IgG", "HlyE_IgA"), - num_cores = 8 # Allow for parallel processing to decrease run time - ) - - expect_equal(est_true, est_false) -}) test_that("est.incidence.by() issues warning when strata is missing", {