Skip to content

Commit

Permalink
Merge pull request #258 from mrc-ide/bug/progress_bar_timesteps
Browse files Browse the repository at this point in the history
Specify timesteps in create process
  • Loading branch information
giovannic authored Jul 19, 2023
2 parents 7b74c3d + fd58ea6 commit 7fa7ea3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: malariasimulation
Title: An individual based model for malaria
Version: 1.6.0
Version: 1.6.1
Authors@R: c(
person(
given = "Giovanni",
Expand Down
6 changes: 4 additions & 2 deletions R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ run_simulation <- function(
solvers,
correlations,
list(create_lagged_eir(variables, solvers, parameters)),
list(create_lagged_infectivity(variables, parameters))
list(create_lagged_infectivity(variables, parameters)),
timesteps
),
variables = variables,
events = unlist(events),
Expand Down Expand Up @@ -206,6 +207,7 @@ run_metapop_simulation <- function(
correlations[[i]],
lagged_eir,
lagged_infectivity,
timesteps,
mixing[i,],
i
)
Expand Down Expand Up @@ -248,4 +250,4 @@ run_simulation_with_repetitions <- function(
}
)
do.call("rbind", dfs)
}
}
2 changes: 2 additions & 0 deletions R/processes.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#' population and species in the simulation
#' @param lagged_infectivity a list of LaggedValue objects for FOIM for each population
#' in the simulation
#' @param timesteps Number of timesteps
#' @param mixing a vector of mixing coefficients for the lagged transmission
#' values (default: 1)
#' @param mixing_index an index for this population's position in the
Expand All @@ -29,6 +30,7 @@ create_processes <- function(
correlations,
lagged_eir,
lagged_infectivity,
timesteps,
mixing = 1,
mixing_index = 1
) {
Expand Down
2 changes: 1 addition & 1 deletion src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ BEGIN_RCPP
END_RCPP
}

RcppExport SEXP run_testthat_tests();
RcppExport SEXP run_testthat_tests(void);

static const R_CallMethodDef CallEntries[] = {
{"_malariasimulation_create_adult_mosquito_model", (DL_FUNC) &_malariasimulation_create_adult_mosquito_model, 5},
Expand Down
22 changes: 22 additions & 0 deletions tests/testthat/test-process-integration.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@ test_that('create_processes makes valid process functions', {
}
})

test_that('create_processes makes valid process functions when progress bar specified', {
parameters <- get_parameters()
parameters$progress_bar <- TRUE
events <- create_events(parameters)
variables <- create_variables(parameters)
vector_models <- parameterise_mosquito_models(parameters, 1)
solvers <- parameterise_solvers(vector_models, parameters)
renderer <- individual::Render$new(1)
processes <- create_processes(
renderer,
variables,
events,
parameters,
vector_models,
solvers,
timesteps = 100
)
for (process in processes) {
expect(is.function(process) || inherits(process, 'externalptr'), 'Process is not a function')
}
})

test_that('attach_event_listeners makes valid listeners', {
parameters <- get_parameters()
events <- create_events(parameters)
Expand Down

0 comments on commit 7fa7ea3

Please sign in to comment.