Skip to content

Commit

Permalink
update tests that regression test the epiparameter database
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed Sep 13, 2024
1 parent d4b8888 commit 1dd58f5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/parameter_tbl.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
dist_tbl
Output
# Parameter table:
# A data frame: 122 x 7
# A data frame: 125 x 7
disease pathogen epi_distribution prob_distribution author year sample_size
<chr> <chr> <chr> <chr> <chr> <dbl> <dbl>
1 Adenovi~ Adenovi~ incubation peri~ lnorm Lessl~ 2009 14
Expand All @@ -17,7 +17,7 @@
8 Parainf~ Parainf~ incubation peri~ lnorm Lessl~ 2009 11
9 RSV RSV incubation peri~ lnorm Lessl~ 2009 24
10 Rhinovi~ Rhinovi~ incubation peri~ lnorm Lessl~ 2009 28
# i 112 more rows
# i 115 more rows

# parameter_tbl works for incubation period with db

Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/_snaps/print.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
Code
epiparameter_db()
Message
Returning 122 results that match the criteria (99 are parameterised).
Returning 125 results that match the criteria (100 are parameterised).
Use subset to filter by entry variables or single_epiparameter to return a single entry.
To retrieve the citation for each use the 'get_citation' function
Output
# List of 122 <epiparameter> objects
# List of 125 <epiparameter> objects
Number of diseases: 23
> Adenovirus > COVID-19 > Chikungunya > Dengue > Ebola Virus Disease > Hantavirus Pulmonary Syndrome > Human Coronavirus > Influenza > Japanese Encephalitis > MERS > Marburg Virus Disease > Measles > Mpox > Parainfluenza > Pneumonic Plague > RSV > Rhinovirus > Rift Valley Fever > SARS > Smallpox > West Nile Fever > Yellow Fever > Zika Virus Disease
Number of epi distributions: 12
> generation time > hospitalisation to death > hospitalisation to discharge > incubation period > notification to death > notification to discharge > offspring distribution > onset to death > onset to discharge > onset to hospitalisation > onset to ventilation > serial interval
Number of epi distributions: 13
> case fatality risk > generation time > hospitalisation to death > hospitalisation to discharge > incubation period > notification to death > notification to discharge > offspring distribution > onset to death > onset to discharge > onset to hospitalisation > onset to ventilation > serial interval
[[1]]
Disease: Adenovirus
Pathogen: Adenovirus
Expand Down Expand Up @@ -54,7 +54,7 @@
meanlog: 0.660
sdlog: 1.205
# i 119 more elements
# i 122 more elements
# i Use `print(n = ...)` to see more elements.
# i Use `parameter_tbl()` to see a summary table of the parameters.
# i Explore database online at: https://epiverse-trace.github.io/epiparameter/articles/database.html
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-epiparameter.R
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ test_that("c.epiparameter works with <epiparameter> & <multi_epiparameter>", {
test_that("c.multi_epiparameter works with two <multi_epiparameter>s", {
res <- c(db, db)
expect_s3_class(res, class = "multi_epiparameter")
expect_length(res, 244)
expect_length(res, 250)
expect_s3_class(res[[1]], class = "epiparameter")
})

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-epiparameter_db.R
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ test_that(".read_epiparameter_db works as expected", {
db <- .read_epiparameter_db()
expect_s3_class(db, class = "multi_epiparameter")
expect_type(db, type = "list")
expect_length(db, 122)
expect_length(db, 125)
expect_true(all(vapply(db, is_epiparameter, FUN.VALUE = logical(1))))
})

Expand Down Expand Up @@ -244,7 +244,7 @@ test_that("as.data.frame works for <multi_epiparameter>", {
db <- suppressMessages(epiparameter_db())
df <- as.data.frame(db)
expect_s3_class(df, class = "data.frame")
expect_identical(dim(df), c(122L, 10L))
expect_identical(dim(df), c(125L, 10L))
expect_identical(
colnames(df),
c("disease", "pathogen", "epi_distribution", "prob_distribution",
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-parameter_tbl.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ db <- suppressMessages(epiparameter_db())
test_that("parameter_tbl works as expected supplied with db", {
dist_tbl <- parameter_tbl(multi_epiparameter = db)
expect_s3_class(dist_tbl, "data.frame")
expect_identical(dim(dist_tbl), c(122L, 7L))
expect_identical(dim(dist_tbl), c(125L, 7L))
expect_named(
dist_tbl,
c("disease", "pathogen", "epi_distribution", "prob_distribution",
Expand Down

0 comments on commit 1dd58f5

Please sign in to comment.