Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding in n_spray output #310

Merged
merged 13 commits into from
May 28, 2024
4 changes: 2 additions & 2 deletions R/processes.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ create_processes <- function(
)

# =========
# RTS,S EPI
# PEV EPI
# =========
if (!is.null(parameters$pev_epi_coverage)) {
processes <- c(
Expand Down Expand Up @@ -250,7 +250,7 @@ create_processes <- function(
if (parameters$spraying) {
processes <- c(
processes,
indoor_spraying(variables$spray_time, parameters, correlations)
indoor_spraying(variables$spray_time, renderer, parameters, correlations)
)
}

Expand Down
5 changes: 4 additions & 1 deletion R/vector_control.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ prob_bitten <- function(
#' `get_correlation_parameters`
#'
#' @param spray_time the variable for the time of spraying
#' @param renderer model rendering object
#' @param parameters the model parameters
htopazian marked this conversation as resolved.
Show resolved Hide resolved
#' @param correlations correlation parameters
#' @noRd
indoor_spraying <- function(spray_time, parameters, correlations) {
indoor_spraying <- function(spray_time, renderer, parameters, correlations) {
renderer$set_default('n_spray', 0)
function(timestep) {
matches <- timestep == parameters$spraying_timesteps
if (any(matches)) {
Expand All @@ -116,6 +118,7 @@ indoor_spraying <- function(spray_time, parameters, correlations) {
correlations
))
spray_time$queue_update(timestep, target)
renderer$render('n_spray', length(target), timestep)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-vector-control.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,11 @@ test_that('indoor_spraying process sets spray_time correctly', {
ms_gamma = matrix(c(-0.009, -0.009), nrow=2, ncol=1)
)
spray_time <- mock_double(rep(0, 4))
renderer <- individual::Render$new(timestep)
correlations <- get_correlation_parameters(parameters)
process <- indoor_spraying(
spray_time,
renderer,
parameters,
correlations
)
Expand Down
Loading