Skip to content

Commit

Permalink
tests and typo fix
Browse files Browse the repository at this point in the history
  • Loading branch information
OJWatson committed Jan 20, 2023
1 parent 4655884 commit ee9ec80
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
^PlottingScripts&
R/ring-simulation7.R
^tools/
PlottingScripts
PlottingScripts
News.md
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: hrp2malaRia
Type: Package
Title: pfhrp2 gene deletion malaria modelling
Version: 0.1.1
Date: 2019-03-20
Version: 0.1.2
Date: 2023-01-20
Author: OJ Watson
Maintainer: <[email protected]>
Description: Individual based malaria transmission model.
Expand All @@ -13,9 +13,11 @@ Imports:
reshape2,
shiny
Suggests:
context
context,
testthat (>= 3.0.0)
License: MIT + file LICENSE
LazyData: TRUE
RoxygenNote: 7.1.2
Encoding: UTF-8
Remotes: mrc-ide/context
Config/testthat/edition: 3
4 changes: 4 additions & 0 deletions R/NEWS.md → NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## hrp2malaRia 0.1.2

* Fix to hrp2_Simulation introduced during previous version

## hrp2malaRia 0.1.1

* microscopy 2-10 and PCR all ages now tracked in series
Expand Down
2 changes: 1 addition & 1 deletion R/hrp2-simulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,7 @@ hrp2_Simulation <- function(

# Microscopy 2-10
pos.2.10 <- which(res$Age<(365*10) & res$Age>(365*2))
total.2.10.over.time <- length(pos.2.10) * storage_capture
pos.2.10_D.T <- arrayInd(which(res$Status[pos.2.10,last.7] %in% c(2,5)), dim(res$Status[pos.2.10,]))
pos.2.10_A <- which(res$Status[pos.2.10,last.7] == 3, arr.ind = TRUE)
pos.2.10_U <- which(res$Status[pos.2.10,last.7] == 4, arr.ind = TRUE)
Expand Down Expand Up @@ -1174,7 +1175,6 @@ hrp2_Simulation <- function(

# PCR All age
pos.allage_U <- which(res$Status[,last.7] == 4, arr.ind = TRUE)
total.2.10.over.time <- length(pos.2.10) * storage_capture

# detectability of Us for PCR and microscopy all age
f.D.U <- 1 - ((1 - f.D0) / (1 + ((res$Age[pos.allage_U[,1]] / a.D)^g.D)))
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/tests.html
# * https://testthat.r-lib.org/reference/test_package.html#special-files

library(testthat)
library(hrp2malaRia)

test_check("hrp2malaRia")
12 changes: 12 additions & 0 deletions tests/testthat/test-runs.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
test_that("sim runs", {
expect_output(
r <- hrp2malaRia::hrp2_Simulation(EIR = 1, N = 1000, years = 0.4)
)
expect_true("Buffer" %in% names(r))

expect_output(
r <- hrp2malaRia::hrp2_Simulation(EIR = 1, N = 1000, years = 0.4,
just_storage_results = TRUE)
)
expect_false("Buffer" %in% names(r))
})

0 comments on commit ee9ec80

Please sign in to comment.