From 640d6fa6608cdcff9a623781e3b4021e0b344de2 Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 11:25:51 +0100 Subject: [PATCH 01/14] add new time series --- R/model_run.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/model_run.R b/R/model_run.R index dfe9b58..eca6707 100644 --- a/R/model_run.R +++ b/R/model_run.R @@ -41,6 +41,12 @@ model_run <- function(parameters, model_version) { ) time_series$vaccinated <- vax_time_series$vaccinated + # get incidence time series + time_series$new_infections <- daedalus::get_incidence(model_results, "infections")$value + time_series$new_hospitalised <- daedalus::get_incidence(model_results, "hospitalisations")$value + time_series$new_deaths <- daedalus::get_incidence(model_results, "deaths")$value + time_series$new_vaccinated <- daedalus::get_new_vaccinations(model_results)$new_vaccinations + raw_costs <- daedalus::get_costs(model_results) costs <- get_nested_costs(raw_costs) From 7d7d610297d9cbf1bd3fca41e3b103187b57506b Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 11:32:20 +0100 Subject: [PATCH 02/14] time series metadata --- R/model_run.R | 4 ++-- inst/json/metadata_0.1.0.json | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/R/model_run.R b/R/model_run.R index eca6707..6ca6309 100644 --- a/R/model_run.R +++ b/R/model_run.R @@ -43,9 +43,9 @@ model_run <- function(parameters, model_version) { # get incidence time series time_series$new_infections <- daedalus::get_incidence(model_results, "infections")$value - time_series$new_hospitalised <- daedalus::get_incidence(model_results, "hospitalisations")$value + time_series$new_hospitalisations <- daedalus::get_incidence(model_results, "hospitalisations")$value time_series$new_deaths <- daedalus::get_incidence(model_results, "deaths")$value - time_series$new_vaccinated <- daedalus::get_new_vaccinations(model_results)$new_vaccinations + time_series$new_vaccinations <- daedalus::get_new_vaccinations(model_results)$new_vaccinations raw_costs <- daedalus::get_costs(model_results) costs <- get_nested_costs(raw_costs) diff --git a/inst/json/metadata_0.1.0.json b/inst/json/metadata_0.1.0.json index d3d3fba..bacc1de 100644 --- a/inst/json/metadata_0.1.0.json +++ b/inst/json/metadata_0.1.0.json @@ -107,7 +107,11 @@ "description": "Number of infectious individuals, comprising both symptomatic and asymptomatic infections, including those in need of hospitalisation." }, { "id": "hospitalised", "label": "Hospital demand", "description": "Infections requiring hospitalisation" }, { "id": "dead", "label": "Dead", "description": "Total deaths" }, - { "id": "vaccinated", "label": "Vaccinated", "description": "Total number of vaccinations administered" } + { "id": "vaccinated", "label": "Vaccinated", "description": "Total number of vaccinations administered" }, + { "id": "new_infections", "label": "New Infections", "description": "Number of new infections per day" }, + { "id": "new_hospitalisations", "label": "New Hospitalisations", "description": "Number of patients who are hospitalised per day" }, + { "id": "new_deaths", "label": "New deaths", "description": "Number of deaths per day" }, + { "id": "new_vaccinations", "label": "New vaccinations", "descriptions": "Number of vaccinations per day" } ] } } From 9e01b1d99e63dec1faec5a83842e3989c6b13625 Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 12:59:58 +0100 Subject: [PATCH 03/14] add metadata --- inst/json/metadata_0.1.0.json | 40 ++++++++++++++++++++++++++++++++++- inst/schema/metadata.json | 19 +++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/inst/json/metadata_0.1.0.json b/inst/json/metadata_0.1.0.json index bacc1de..939ab18 100644 --- a/inst/json/metadata_0.1.0.json +++ b/inst/json/metadata_0.1.0.json @@ -113,5 +113,43 @@ { "id": "new_deaths", "label": "New deaths", "description": "Number of deaths per day" }, { "id": "new_vaccinations", "label": "New vaccinations", "descriptions": "Number of vaccinations per day" } ] - } + }, + "time_series_roles": [ + {"id": "total", "label": "Total"}, + {"id": "daily", "label": "Daily"} + ], + "time_series_groups": [ + { + "id": "infections", + "label": "Infections", + "time_series": { + "total": "prevalence", + "daily": "new_infections" + } + }, + { + "id": "hospitalisations", + "label": "Hospitalisations", + "time_series": { + "total": "hospitalised", + "daily": "new_hospitalisations" + } + }, + { + "id": "deaths", + "label": "Deaths", + "time_series": { + "total": "dead", + "daily": "new_deaths" + } + }, + { + "id": "vaccinations", + "label": "Vaccinations", + "time_series": { + "total": "vaccinated", + "daily": "new_vaccinations" + } + } + ] } diff --git a/inst/schema/metadata.json b/inst/schema/metadata.json index 9c12d56..3464b27 100644 --- a/inst/schema/metadata.json +++ b/inst/schema/metadata.json @@ -93,6 +93,25 @@ "items": { "$ref": "#/$defs/displayInfo" } + }, + "time_series_roles": { + "type": "array", + "items": { + "$ref": "#/$defs/displayInfo" + } + }, + "time_series_groups": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { "type": "string" }, + "label": { "type": "string" }, + "time_series": { "type": "object" } + }, + "additionalProperties": false, + "required": ["id", "label", "time_series"] + } } }, "additionalProperties": false, From 1276b19d79f967c9dd885ddc8059c033069d0066 Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 13:14:54 +0100 Subject: [PATCH 04/14] unit test --- tests/testthat/test-zzz-e2e.R | 5 +++++ tests/testthat/test_model_run.R | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/tests/testthat/test-zzz-e2e.R b/tests/testthat/test-zzz-e2e.R index be26484..e0444c4 100644 --- a/tests/testthat/test-zzz-e2e.R +++ b/tests/testthat/test-zzz-e2e.R @@ -1,3 +1,4 @@ +skip() check_for_redis() temp_dir <- tempdir() # Env vars required by the queue @@ -91,6 +92,10 @@ test_that("can run model, get status and results", { expect_length(results_data$time_series$prevalence, time_series_length) expect_length(results_data$time_series$hospitalised, time_series_length) expect_length(results_data$time_series$dead, time_series_length) + expect_length(results_data$time_series$new_infections, time_series_length) + expect_length(results_data$time_series$new_hospitalisations, time_series_length) + expect_length(results_data$time_series$new_deaths, time_series_length) + expect_length(results_data$time_series$new_vaccinations, time_series_length) expect_gt(results_data$gdp, 0) diff --git a/tests/testthat/test_model_run.R b/tests/testthat/test_model_run.R index 297a314..9c8ed62 100644 --- a/tests/testthat/test_model_run.R +++ b/tests/testthat/test_model_run.R @@ -14,6 +14,13 @@ test_that("can run model and return results", { mockery::stub(model_run, "daedalus::get_data", mock_model_data) + mock_incidence_result <- list(value = c(10, 20)) + mock_get_incidence <- mockery::mock(mock_incidence_result) + mockery::stub(model_run, "daedalus::get_incidence", mock_get_incidence) + + mock_new_vaccinations_result <- list(new_vaccinations = c(100, 200)) + mockery::stub(model_run, "daedalus::get_new_vaccinations", mock_new_vaccinations_result) + mock_costs_data <- daedalus_mock_costs() mock_get_costs <- mockery::mock(mock_costs_data) mockery::stub(model_run, "daedalus::get_costs", mock_get_costs) @@ -39,6 +46,12 @@ test_that("can run model and return results", { ) ) + expect_identical( + mockery::mock_args(mock_get_incidence)[[1]], + list(mock_results, "infections") + ) + # TODO check other calls + expect_named(res, c( "parameters", "costs", @@ -55,6 +68,10 @@ test_that("can run model and return results", { expect_identical(res$time_series$hospitalised, c(11L, 31L)) expect_identical(res$time_series$dead, c(15L, 37L)) expect_identical(res$time_series$vaccinated, c(1L, 5L)) + expect_identical(res$time_series$new_infections, mock_incidence_result$value) + expect_identical(res$time_series$new_hospitalisations, mock_incidence_result$value) + expect_identical(res$time_series$new_deaths, mock_incidence_result$value) + expect_identical(res$time_series$new_vaccinations, mock_new_vaccinations_result$new_vaccinations) expect_identical(res$parameters, parameters) expect_nested_mock_costs(res$costs) expect_identical(res$interventions, list( From b1442da6fcddc9321af201ed94e36a0ac6d6f524 Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 13:42:03 +0100 Subject: [PATCH 05/14] fix schema --- inst/json/metadata_0.1.0.json | 80 ++++++++++++++++----------------- tests/testthat/test-zzz-e2e.R | 1 - tests/testthat/test_model_run.R | 8 +++- 3 files changed, 46 insertions(+), 43 deletions(-) diff --git a/inst/json/metadata_0.1.0.json b/inst/json/metadata_0.1.0.json index 939ab18..e741962 100644 --- a/inst/json/metadata_0.1.0.json +++ b/inst/json/metadata_0.1.0.json @@ -111,45 +111,45 @@ { "id": "new_infections", "label": "New Infections", "description": "Number of new infections per day" }, { "id": "new_hospitalisations", "label": "New Hospitalisations", "description": "Number of patients who are hospitalised per day" }, { "id": "new_deaths", "label": "New deaths", "description": "Number of deaths per day" }, - { "id": "new_vaccinations", "label": "New vaccinations", "descriptions": "Number of vaccinations per day" } - ] - }, - "time_series_roles": [ - {"id": "total", "label": "Total"}, - {"id": "daily", "label": "Daily"} - ], - "time_series_groups": [ - { - "id": "infections", - "label": "Infections", - "time_series": { - "total": "prevalence", - "daily": "new_infections" - } - }, - { - "id": "hospitalisations", - "label": "Hospitalisations", - "time_series": { - "total": "hospitalised", - "daily": "new_hospitalisations" - } - }, - { - "id": "deaths", - "label": "Deaths", - "time_series": { - "total": "dead", - "daily": "new_deaths" - } - }, - { - "id": "vaccinations", - "label": "Vaccinations", - "time_series": { - "total": "vaccinated", - "daily": "new_vaccinations" + { "id": "new_vaccinations", "label": "New vaccinations", "description": "Number of vaccinations per day" } + ], + "time_series_roles": [ + {"id": "total", "label": "Total"}, + {"id": "daily", "label": "Daily"} + ], + "time_series_groups": [ + { + "id": "infections", + "label": "Infections", + "time_series": { + "total": "prevalence", + "daily": "new_infections" + } + }, + { + "id": "hospitalisations", + "label": "Hospitalisations", + "time_series": { + "total": "hospitalised", + "daily": "new_hospitalisations" + } + }, + { + "id": "deaths", + "label": "Deaths", + "time_series": { + "total": "dead", + "daily": "new_deaths" + } + }, + { + "id": "vaccinations", + "label": "Vaccinations", + "time_series": { + "total": "vaccinated", + "daily": "new_vaccinations" + } } - } - ] + ] + } } diff --git a/tests/testthat/test-zzz-e2e.R b/tests/testthat/test-zzz-e2e.R index e0444c4..ecf13b5 100644 --- a/tests/testthat/test-zzz-e2e.R +++ b/tests/testthat/test-zzz-e2e.R @@ -1,4 +1,3 @@ -skip() check_for_redis() temp_dir <- tempdir() # Env vars required by the queue diff --git a/tests/testthat/test_model_run.R b/tests/testthat/test_model_run.R index 9c8ed62..98ee22f 100644 --- a/tests/testthat/test_model_run.R +++ b/tests/testthat/test_model_run.R @@ -15,7 +15,7 @@ test_that("can run model and return results", { mockery::stub(model_run, "daedalus::get_data", mock_model_data) mock_incidence_result <- list(value = c(10, 20)) - mock_get_incidence <- mockery::mock(mock_incidence_result) + mock_get_incidence <- mockery::mock(mock_incidence_result, cycle=TRUE) mockery::stub(model_run, "daedalus::get_incidence", mock_get_incidence) mock_new_vaccinations_result <- list(new_vaccinations = c(100, 200)) @@ -63,7 +63,11 @@ test_that("can run model and return results", { expect_named(res$time_series, c("prevalence", "hospitalised", "dead", - "vaccinated")) + "vaccinated", + "new_infections", + "new_hospitalisations", + "new_deaths", + "new_vaccinations")) expect_identical(res$time_series$prevalence, c(28L, 87L)) expect_identical(res$time_series$hospitalised, c(11L, 31L)) expect_identical(res$time_series$dead, c(15L, 37L)) From c8bd90ad8762a49cf1d2c596d4e7a54a6128ff25 Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 13:44:03 +0100 Subject: [PATCH 06/14] test get_incidence calls --- tests/testthat/test_model_run.R | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test_model_run.R b/tests/testthat/test_model_run.R index 98ee22f..72cdb94 100644 --- a/tests/testthat/test_model_run.R +++ b/tests/testthat/test_model_run.R @@ -50,7 +50,14 @@ test_that("can run model and return results", { mockery::mock_args(mock_get_incidence)[[1]], list(mock_results, "infections") ) - # TODO check other calls + expect_identical( + mockery::mock_args(mock_get_incidence)[[2]], + list(mock_results, "hospitalisations") + ) + expect_identical( + mockery::mock_args(mock_get_incidence)[[3]], + list(mock_results, "deaths") + ) expect_named(res, c( "parameters", From 5bdcc2d2d94d046da2204b4fc9b59a296d24f5b0 Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 13:50:56 +0100 Subject: [PATCH 07/14] lint --- R/model_run.R | 12 ++++++++---- tests/testthat/test-zzz-e2e.R | 3 ++- tests/testthat/test_model_run.R | 12 ++++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/R/model_run.R b/R/model_run.R index 6ca6309..66d3387 100644 --- a/R/model_run.R +++ b/R/model_run.R @@ -42,10 +42,14 @@ model_run <- function(parameters, model_version) { time_series$vaccinated <- vax_time_series$vaccinated # get incidence time series - time_series$new_infections <- daedalus::get_incidence(model_results, "infections")$value - time_series$new_hospitalisations <- daedalus::get_incidence(model_results, "hospitalisations")$value - time_series$new_deaths <- daedalus::get_incidence(model_results, "deaths")$value - time_series$new_vaccinations <- daedalus::get_new_vaccinations(model_results)$new_vaccinations + time_series$new_infections <- + daedalus::get_incidence(model_results, "infections")$value + time_series$new_hospitalisations <- + daedalus::get_incidence(model_results, "hospitalisations")$value + time_series$new_deaths <- + daedalus::get_incidence(model_results, "deaths")$value + time_series$new_vaccinations <- + daedalus::get_new_vaccinations(model_results)$new_vaccinations raw_costs <- daedalus::get_costs(model_results) costs <- get_nested_costs(raw_costs) diff --git a/tests/testthat/test-zzz-e2e.R b/tests/testthat/test-zzz-e2e.R index ecf13b5..3ffe192 100644 --- a/tests/testthat/test-zzz-e2e.R +++ b/tests/testthat/test-zzz-e2e.R @@ -92,7 +92,8 @@ test_that("can run model, get status and results", { expect_length(results_data$time_series$hospitalised, time_series_length) expect_length(results_data$time_series$dead, time_series_length) expect_length(results_data$time_series$new_infections, time_series_length) - expect_length(results_data$time_series$new_hospitalisations, time_series_length) + expect_length(results_data$time_series$new_hospitalisations, + time_series_length) expect_length(results_data$time_series$new_deaths, time_series_length) expect_length(results_data$time_series$new_vaccinations, time_series_length) diff --git a/tests/testthat/test_model_run.R b/tests/testthat/test_model_run.R index 72cdb94..36cde86 100644 --- a/tests/testthat/test_model_run.R +++ b/tests/testthat/test_model_run.R @@ -15,11 +15,13 @@ test_that("can run model and return results", { mockery::stub(model_run, "daedalus::get_data", mock_model_data) mock_incidence_result <- list(value = c(10, 20)) - mock_get_incidence <- mockery::mock(mock_incidence_result, cycle=TRUE) + mock_get_incidence <- mockery::mock(mock_incidence_result, + cycle=TRUE) mockery::stub(model_run, "daedalus::get_incidence", mock_get_incidence) mock_new_vaccinations_result <- list(new_vaccinations = c(100, 200)) - mockery::stub(model_run, "daedalus::get_new_vaccinations", mock_new_vaccinations_result) + mockery::stub(model_run, "daedalus::get_new_vaccinations", + mock_new_vaccinations_result) mock_costs_data <- daedalus_mock_costs() mock_get_costs <- mockery::mock(mock_costs_data) @@ -80,9 +82,11 @@ test_that("can run model and return results", { expect_identical(res$time_series$dead, c(15L, 37L)) expect_identical(res$time_series$vaccinated, c(1L, 5L)) expect_identical(res$time_series$new_infections, mock_incidence_result$value) - expect_identical(res$time_series$new_hospitalisations, mock_incidence_result$value) + expect_identical(res$time_series$new_hospitalisations, + mock_incidence_result$value) expect_identical(res$time_series$new_deaths, mock_incidence_result$value) - expect_identical(res$time_series$new_vaccinations, mock_new_vaccinations_result$new_vaccinations) + expect_identical(res$time_series$new_vaccinations, + mock_new_vaccinations_result$new_vaccinations) expect_identical(res$parameters, parameters) expect_nested_mock_costs(res$costs) expect_identical(res$interventions, list( From c66e074011d278501ab6ab67325211865d0a3db6 Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 13:53:51 +0100 Subject: [PATCH 08/14] more lint --- tests/testthat/test_model_run.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test_model_run.R b/tests/testthat/test_model_run.R index 36cde86..752bebf 100644 --- a/tests/testthat/test_model_run.R +++ b/tests/testthat/test_model_run.R @@ -16,7 +16,7 @@ test_that("can run model and return results", { mock_incidence_result <- list(value = c(10, 20)) mock_get_incidence <- mockery::mock(mock_incidence_result, - cycle=TRUE) + cycle = TRUE) mockery::stub(model_run, "daedalus::get_incidence", mock_get_incidence) mock_new_vaccinations_result <- list(new_vaccinations = c(100, 200)) From aa1d4a5c289ecd4778299fe4c5c3b5f06fd857ee Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 15:49:25 +0100 Subject: [PATCH 09/14] call get_incidence once only --- R/model_run.R | 14 ++++++++------ tests/testthat/test_model_run.R | 23 +++++++++-------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/R/model_run.R b/R/model_run.R index 66d3387..87bb7ce 100644 --- a/R/model_run.R +++ b/R/model_run.R @@ -42,12 +42,14 @@ model_run <- function(parameters, model_version) { time_series$vaccinated <- vax_time_series$vaccinated # get incidence time series - time_series$new_infections <- - daedalus::get_incidence(model_results, "infections")$value - time_series$new_hospitalisations <- - daedalus::get_incidence(model_results, "hospitalisations")$value - time_series$new_deaths <- - daedalus::get_incidence(model_results, "deaths")$value + incidences <- daedalus::get_incidence(model_results) + incidences <- tidyr::pivot_wider( + incidences, id_cols = "time", names_from = "measure" + ) + time_series$new_infections <- incidences$daily_infections + time_series$new_hospitalisations <- incidences$daily_hospitalisations + time_series$new_deaths <- incidences$daily_deaths + time_series$new_vaccinations <- daedalus::get_new_vaccinations(model_results)$new_vaccinations diff --git a/tests/testthat/test_model_run.R b/tests/testthat/test_model_run.R index 752bebf..63aff50 100644 --- a/tests/testthat/test_model_run.R +++ b/tests/testthat/test_model_run.R @@ -14,7 +14,11 @@ test_that("can run model and return results", { mockery::stub(model_run, "daedalus::get_data", mock_model_data) - mock_incidence_result <- list(value = c(10, 20)) + mock_incidence_result <- data.frame( + time = c(1, 2, 1, 2, 1, 2), + measure = c("daily_infections", "daily_infections", "daily_hospitalisations", "daily_hospitalisations", "daily_deaths", "daily_deaths"), + value = c(100L, 200L, 10L, 20L, 1L, 2L) + ) mock_get_incidence <- mockery::mock(mock_incidence_result, cycle = TRUE) mockery::stub(model_run, "daedalus::get_incidence", mock_get_incidence) @@ -50,15 +54,7 @@ test_that("can run model and return results", { expect_identical( mockery::mock_args(mock_get_incidence)[[1]], - list(mock_results, "infections") - ) - expect_identical( - mockery::mock_args(mock_get_incidence)[[2]], - list(mock_results, "hospitalisations") - ) - expect_identical( - mockery::mock_args(mock_get_incidence)[[3]], - list(mock_results, "deaths") + list(mock_results) ) expect_named(res, c( @@ -81,10 +77,9 @@ test_that("can run model and return results", { expect_identical(res$time_series$hospitalised, c(11L, 31L)) expect_identical(res$time_series$dead, c(15L, 37L)) expect_identical(res$time_series$vaccinated, c(1L, 5L)) - expect_identical(res$time_series$new_infections, mock_incidence_result$value) - expect_identical(res$time_series$new_hospitalisations, - mock_incidence_result$value) - expect_identical(res$time_series$new_deaths, mock_incidence_result$value) + expect_identical(res$time_series$new_infections, c(100L, 200L)) + expect_identical(res$time_series$new_hospitalisations, c(10L, 20L)) + expect_identical(res$time_series$new_deaths, c(1L, 2L)) expect_identical(res$time_series$new_vaccinations, mock_new_vaccinations_result$new_vaccinations) expect_identical(res$parameters, parameters) From 6286cda276b10110a35bee8024ef70f1f788858e Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 15:56:58 +0100 Subject: [PATCH 10/14] update time series names --- R/model_run.R | 8 ++++---- inst/json/metadata_0.1.0.json | 16 ++++++++-------- tests/testthat/test_model_run.R | 16 ++++++++-------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/R/model_run.R b/R/model_run.R index 87bb7ce..81c477e 100644 --- a/R/model_run.R +++ b/R/model_run.R @@ -46,11 +46,11 @@ model_run <- function(parameters, model_version) { incidences <- tidyr::pivot_wider( incidences, id_cols = "time", names_from = "measure" ) - time_series$new_infections <- incidences$daily_infections - time_series$new_hospitalisations <- incidences$daily_hospitalisations - time_series$new_deaths <- incidences$daily_deaths + time_series$new_infected <- incidences$daily_infections + time_series$new_hospitalised <- incidences$daily_hospitalisations + time_series$new_dead <- incidences$daily_deaths - time_series$new_vaccinations <- + time_series$new_vaccinated <- daedalus::get_new_vaccinations(model_results)$new_vaccinations raw_costs <- daedalus::get_costs(model_results) diff --git a/inst/json/metadata_0.1.0.json b/inst/json/metadata_0.1.0.json index e741962..6aa50fe 100644 --- a/inst/json/metadata_0.1.0.json +++ b/inst/json/metadata_0.1.0.json @@ -108,10 +108,10 @@ { "id": "hospitalised", "label": "Hospital demand", "description": "Infections requiring hospitalisation" }, { "id": "dead", "label": "Dead", "description": "Total deaths" }, { "id": "vaccinated", "label": "Vaccinated", "description": "Total number of vaccinations administered" }, - { "id": "new_infections", "label": "New Infections", "description": "Number of new infections per day" }, - { "id": "new_hospitalisations", "label": "New Hospitalisations", "description": "Number of patients who are hospitalised per day" }, - { "id": "new_deaths", "label": "New deaths", "description": "Number of deaths per day" }, - { "id": "new_vaccinations", "label": "New vaccinations", "description": "Number of vaccinations per day" } + { "id": "new_infected", "label": "New infections", "description": "Number of new infections per day" }, + { "id": "new_hospitalised", "label": "New hospitalisations", "description": "Number of patients who are hospitalised per day" }, + { "id": "new_dead", "label": "New deaths", "description": "Number of deaths per day" }, + { "id": "new_vaccinated", "label": "New vaccinations", "description": "Number of vaccinations per day" } ], "time_series_roles": [ {"id": "total", "label": "Total"}, @@ -123,7 +123,7 @@ "label": "Infections", "time_series": { "total": "prevalence", - "daily": "new_infections" + "daily": "new_infected" } }, { @@ -131,7 +131,7 @@ "label": "Hospitalisations", "time_series": { "total": "hospitalised", - "daily": "new_hospitalisations" + "daily": "new_hospitalised" } }, { @@ -139,7 +139,7 @@ "label": "Deaths", "time_series": { "total": "dead", - "daily": "new_deaths" + "daily": "new_dead" } }, { @@ -147,7 +147,7 @@ "label": "Vaccinations", "time_series": { "total": "vaccinated", - "daily": "new_vaccinations" + "daily": "new_vaccinated" } } ] diff --git a/tests/testthat/test_model_run.R b/tests/testthat/test_model_run.R index 63aff50..931af54 100644 --- a/tests/testthat/test_model_run.R +++ b/tests/testthat/test_model_run.R @@ -69,18 +69,18 @@ test_that("can run model and return results", { "hospitalised", "dead", "vaccinated", - "new_infections", - "new_hospitalisations", - "new_deaths", - "new_vaccinations")) + "new_infected", + "new_hospitalised", + "new_dead", + "new_vaccinated")) expect_identical(res$time_series$prevalence, c(28L, 87L)) expect_identical(res$time_series$hospitalised, c(11L, 31L)) expect_identical(res$time_series$dead, c(15L, 37L)) expect_identical(res$time_series$vaccinated, c(1L, 5L)) - expect_identical(res$time_series$new_infections, c(100L, 200L)) - expect_identical(res$time_series$new_hospitalisations, c(10L, 20L)) - expect_identical(res$time_series$new_deaths, c(1L, 2L)) - expect_identical(res$time_series$new_vaccinations, + expect_identical(res$time_series$new_infected, c(100L, 200L)) + expect_identical(res$time_series$new_hospitalised, c(10L, 20L)) + expect_identical(res$time_series$new_dead, c(1L, 2L)) + expect_identical(res$time_series$new_vaccinated, mock_new_vaccinations_result$new_vaccinations) expect_identical(res$parameters, parameters) expect_nested_mock_costs(res$costs) From c601838dc22ce8634460af5ad92905011beecff3 Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 15:58:31 +0100 Subject: [PATCH 11/14] update new hosp description --- inst/json/metadata_0.1.0.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/json/metadata_0.1.0.json b/inst/json/metadata_0.1.0.json index 6aa50fe..d1529af 100644 --- a/inst/json/metadata_0.1.0.json +++ b/inst/json/metadata_0.1.0.json @@ -109,7 +109,7 @@ { "id": "dead", "label": "Dead", "description": "Total deaths" }, { "id": "vaccinated", "label": "Vaccinated", "description": "Total number of vaccinations administered" }, { "id": "new_infected", "label": "New infections", "description": "Number of new infections per day" }, - { "id": "new_hospitalised", "label": "New hospitalisations", "description": "Number of patients who are hospitalised per day" }, + { "id": "new_hospitalised", "label": "New hospitalisations", "description": "Number of new patients in need of hospitalisation per day" }, { "id": "new_dead", "label": "New deaths", "description": "Number of deaths per day" }, { "id": "new_vaccinated", "label": "New vaccinations", "description": "Number of vaccinations per day" } ], From 140b7cc8e820ff865a3781f798299cdb79bfb903 Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 15:59:09 +0100 Subject: [PATCH 12/14] shorten long line --- tests/testthat/test_model_run.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test_model_run.R b/tests/testthat/test_model_run.R index 931af54..aed134f 100644 --- a/tests/testthat/test_model_run.R +++ b/tests/testthat/test_model_run.R @@ -16,7 +16,9 @@ test_that("can run model and return results", { mock_incidence_result <- data.frame( time = c(1, 2, 1, 2, 1, 2), - measure = c("daily_infections", "daily_infections", "daily_hospitalisations", "daily_hospitalisations", "daily_deaths", "daily_deaths"), + measure = c("daily_infections", "daily_infections", + "daily_hospitalisations", "daily_hospitalisations", + "daily_deaths", "daily_deaths"), value = c(100L, 200L, 10L, 20L, 1L, 2L) ) mock_get_incidence <- mockery::mock(mock_incidence_result, From 4c793d12546d5e4ed6ad470013ac7ea798fedac3 Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 16:03:10 +0100 Subject: [PATCH 13/14] update e2e test --- tests/testthat/test-zzz-e2e.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-zzz-e2e.R b/tests/testthat/test-zzz-e2e.R index 3ffe192..3892b6e 100644 --- a/tests/testthat/test-zzz-e2e.R +++ b/tests/testthat/test-zzz-e2e.R @@ -91,11 +91,11 @@ test_that("can run model, get status and results", { expect_length(results_data$time_series$prevalence, time_series_length) expect_length(results_data$time_series$hospitalised, time_series_length) expect_length(results_data$time_series$dead, time_series_length) - expect_length(results_data$time_series$new_infections, time_series_length) - expect_length(results_data$time_series$new_hospitalisations, + expect_length(results_data$time_series$new_infected, time_series_length) + expect_length(results_data$time_series$new_hospitalised, time_series_length) - expect_length(results_data$time_series$new_deaths, time_series_length) - expect_length(results_data$time_series$new_vaccinations, time_series_length) + expect_length(results_data$time_series$new_dead, time_series_length) + expect_length(results_data$time_series$new_vaccinated, time_series_length) expect_gt(results_data$gdp, 0) From 3f5e97bb9d87b632b5d0ed14ed128d92d1ffaf3d Mon Sep 17 00:00:00 2001 From: Emma Date: Mon, 21 Oct 2024 16:10:28 +0100 Subject: [PATCH 14/14] lint --- tests/testthat/test_model_run.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test_model_run.R b/tests/testthat/test_model_run.R index aed134f..0c215fe 100644 --- a/tests/testthat/test_model_run.R +++ b/tests/testthat/test_model_run.R @@ -19,7 +19,8 @@ test_that("can run model and return results", { measure = c("daily_infections", "daily_infections", "daily_hospitalisations", "daily_hospitalisations", "daily_deaths", "daily_deaths"), - value = c(100L, 200L, 10L, 20L, 1L, 2L) + value = c(100L, 200L, 10L, 20L, 1L, 2L), + stringsAsFactors = FALSE ) mock_get_incidence <- mockery::mock(mock_incidence_result, cycle = TRUE)