From 8930897a50428ff8532455bcc50c610ed003a87a Mon Sep 17 00:00:00 2001 From: RJSheppard Date: Tue, 12 Nov 2024 14:14:50 +0000 Subject: [PATCH] Removed unnecessary code from ls prophylaxis calculation, with corresponding aspect of vivax drug test. --- R/human_infection.R | 1 - tests/testthat/test-vivax.R | 17 ++++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/R/human_infection.R b/R/human_infection.R index 436b543f..10eb1085 100644 --- a/R/human_infection.R +++ b/R/human_infection.R @@ -559,7 +559,6 @@ ls_treatment_prophylaxis_efficacy <- function( ls_drug <- variables$ls_drug$get_values(bite_infections) ls_medicated <- ls_drug > 0 - ls_medicated[ls_medicated] <- !is.na(parameters$drug_hypnozoite_efficacy[ls_drug]) if (any(ls_medicated)) { ls_drug <- ls_drug[ls_medicated] diff --git a/tests/testthat/test-vivax.R b/tests/testthat/test-vivax.R index 1fc629f1..2840fe44 100644 --- a/tests/testthat/test-vivax.R +++ b/tests/testthat/test-vivax.R @@ -345,18 +345,17 @@ test_that('Drug functions provide warnings if applied incorrectly', { test_that('Liver stage prophylaxis functions correctly', { - bite_infections <- individual::Bitset$new(4)$insert(1:4) + bite_infections <- individual::Bitset$new(3)$insert(1:3) variables <- list( - ls_drug = individual::DoubleVariable$new(c(0,1,2,3)), - ls_drug_time = individual::DoubleVariable$new(c(-1,1,1,1)) + ls_drug = individual::DoubleVariable$new(c(0,1,2)), + ls_drug_time = individual::DoubleVariable$new(c(-1,1,1)) ) parms <- get_parameters(parasite = "vivax") |> - set_drugs(drugs = list(CQ_params_vivax, CQ_PQ_params_vivax, CQ_TQ_params_vivax)) |> + set_drugs(drugs = list(CQ_PQ_params_vivax, CQ_TQ_params_vivax)) |> set_clinical_treatment(drug = 1, timesteps = 0, coverages = 0.3) |> - set_clinical_treatment(drug = 2, timesteps = 0, coverages = 0.3) |> - set_clinical_treatment(drug = 3, timesteps = 0, coverages = 0.3) + set_clinical_treatment(drug = 2, timesteps = 0, coverages = 0.3) timestep <- 6 @@ -369,11 +368,11 @@ test_that('Liver stage prophylaxis functions correctly', { expect_identical( ls_prophylaxis, - c(0, 0, + c(0, weibull_survival( c(5,5), - parms$drug_hypnozoite_prophylaxis_shape[c(2, 3)], - parms$drug_hypnozoite_prophylaxis_scale[c(2, 3)] + parms$drug_hypnozoite_prophylaxis_shape[c(1, 2)], + parms$drug_hypnozoite_prophylaxis_scale[c(1, 2)] ) ) )