Skip to content

Commit

Permalink
Cleanup following rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikunterwegs committed Nov 6, 2023
1 parent 5498947 commit f07c996
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 98 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ Imports:
checkmate,
Rcpp,
RcppEigen,
jsonlite,
data.table,
glue,
utils,
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ S3method(print,vaccination)
export(as.intervention)
export(as.vaccination)
export(epidemic_size)
export(get_model_names)
export(get_parameter)
export(get_transmission_rate)
export(infection)
Expand All @@ -24,7 +23,6 @@ export(is_vaccination)
export(model_default_cpp)
export(model_default_r)
export(model_ebola_r)
export(model_library)
export(model_vacamole_cpp)
export(model_vacamole_r)
export(new_infections)
Expand Down
35 changes: 7 additions & 28 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,8 @@
#' as specified in the initial conditions matrix (see [population()]).
#' The second list element is a vector of timesteps.
#' @keywords internal
.model_default_cpp <- function(
initial_state, beta, alpha, gamma, contact_matrix, npi_time_begin,
npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu,
rate_interventions, time_dependence, time_end = 100.0, increment = 1.0) {
.Call(
`_epidemics_model_default_cpp_internal`, initial_state, beta, alpha,
gamma, contact_matrix, npi_time_begin, npi_time_end, npi_cr,
vax_time_begin, vax_time_end, vax_nu, rate_interventions,
time_dependence, time_end, increment
)
.model_default_cpp <- function(initial_state, beta, alpha, gamma, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end = 100.0, increment = 1.0) {
.Call(`_epidemics_model_default_cpp_internal`, initial_state, beta, alpha, gamma, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end, increment)
}

#' @title Run an SEIR model with Erlang passage times
Expand Down Expand Up @@ -81,13 +73,8 @@
#' This output is intended to be passed to [output_to_df()] to be converted
#' into a data.frame for further analysis.
#' @keywords internal
.model_ebola_cpp <- function(
initial_state, population_size, beta, shape_E, rate_E,
shape_I, rate_I, time_end) {
.Call(
`_epidemics_model_ebola_cpp_internal`, initial_state,
population_size, beta, shape_E, rate_E, shape_I, rate_I, time_end
)
.model_ebola_cpp <- function(initial_state, population_size, beta, shape_E, rate_E, shape_I, rate_I, time_end) {
.Call(`_epidemics_model_ebola_cpp_internal`, initial_state, population_size, beta, shape_E, rate_E, shape_I, rate_I, time_end)
}

#' @title Run the RIVM Vacamole model
Expand Down Expand Up @@ -145,17 +132,8 @@
#' as specified in the initial conditions matrix (see [population()]).
#' The second list element is a vector of timesteps.
#' @keywords internal
.model_vacamole_cpp <- function(
initial_state, beta, beta_v, alpha, omega, omega_v, eta, eta_v, gamma,
contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin,
vax_time_end, vax_nu, rate_interventions, time_dependence,
time_end = 100.0, increment = 1.0) {
.Call(
`_epidemics_model_vacamole_cpp_internal`, initial_state, beta, beta_v,
alpha, omega, omega_v, eta, eta_v, gamma, contact_matrix,
npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end,
vax_nu, rate_interventions, time_dependence, time_end, increment
)
.model_vacamole_cpp <- function(initial_state, beta, beta_v, alpha, omega, omega_v, eta, eta_v, gamma, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end = 100.0, increment = 1.0) {
.Call(`_epidemics_model_vacamole_cpp_internal`, initial_state, beta, beta_v, alpha, omega, omega_v, eta, eta_v, gamma, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end, increment)
}

#' @title Compute the discrete probability of the truncated Erlang distribution
Expand All @@ -165,3 +143,4 @@
prob_discrete_erlang_cpp <- function(shape, rate) {
.Call(`_epidemics_prob_discrete_erlang_cpp`, shape, rate)
}

10 changes: 5 additions & 5 deletions R/check_args_default.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @description Check and prepare the four main arguments to
#' [model_default_cpp()] for use with [.model_default_cpp()].
#'
#' `.check_args_epidemic_default()` adds an empty `<intervention>` and
#' `.check_args_model_default()` adds an empty `<intervention>` and
#' `<vaccination>` object if these are missing from the model arguments.
#'
#' `.prepare_args_epidemics_default()` prepares arguments for
Expand All @@ -18,12 +18,12 @@
#'
#' @return
#'
#' `.check_args_epidemic_default()` invisibly returns the model arguments passed
#' `.check_args_model_default()` invisibly returns the model arguments passed
#' in `mod_args`. If the model arguments did not previously contain elements
#' named `intervention` and `vaccination`, these are added as dummy objects of
#' the corresponding classes.
#'
#' `.prepare_args_epidemic_default()` returns a list of model arguments suitable
#' `.prepare_args_model_default()` returns a list of model arguments suitable
#' for [.model_default_cpp()]. This is a named list consisting of:
#'
#' - `initial_state`: the initial conditions modified to represent absolute
Expand Down Expand Up @@ -51,7 +51,7 @@
#' is incremented.
#'
#' @keywords internal
.check_args_epidemic_default <- function(mod_args) {
.check_args_model_default <- function(mod_args) {
# check that arguments list has expected names
checkmate::assert_names(
names(mod_args),
Expand Down Expand Up @@ -148,7 +148,7 @@
#' @name check_prepare_default_args
#' @rdname check_prepare_default_args
#' @keywords internal
.prepare_args_epidemic_default <- function(mod_args) {
.prepare_args_model_default <- function(mod_args) {
# prepare the contact matrix and the initial conditions
# scale the contact matrix by the maximum real eigenvalue
contact_matrix <- get_parameter(mod_args[["population"]], "contact_matrix")
Expand Down
8 changes: 4 additions & 4 deletions R/check_args_ebola.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#' [model_ebola_cpp()] for use with [.model_ebola_cpp()].
#' @return
#'
#' `.check_args_epidemic_ebola()` invisibly returns the model arguments passed
#' `.check_args_model_ebola()` invisibly returns the model arguments passed
#' in `mod_args`.
#'
#' `.prepare_args_epidemic_ebola()` returns a list of model arguments suitable
#' `.prepare_args_model_ebola()` returns a list of model arguments suitable
#' for [.model_ebola_cpp()]. This is a named list consisting of:
#'
#' - `initial_state`: the initial conditions modified to represent absolute
Expand All @@ -29,7 +29,7 @@
#' - `time_end`: the time at which the simulation ends.
#'
#' @keywords internal
.check_args_epidemic_ebola <- function(mod_args) {
.check_args_model_ebola <- function(mod_args) {
# check that arguments list has expected names
checkmate::assert_names(
names(mod_args),
Expand Down Expand Up @@ -60,7 +60,7 @@
#' @name check_prepare_ebola_args
#' @rdname check_prepare_ebola_args
#' @keywords internal
.prepare_args_epidemic_ebola <- function(mod_args) {
.prepare_args_model_ebola <- function(mod_args) {
# prepare initial conditions by scaling with demography
# we take the ceiling to ensure that models with only one
# infectious individual can be accommodated
Expand Down
10 changes: 5 additions & 5 deletions R/check_args_vacamole.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @description Check and prepare the four main arguments to
#' [model_vacamole_cpp()] for use with [.model_vacamole_cpp()].
#'
#' `.check_args_epidemic_vacamole()` adds an empty `<intervention>` object if
#' `.check_args_model_vacamole()` adds an empty `<intervention>` object if
#' this is missing from the model arguments.
#'
#' `.prepare_args_epidemics_vacamole()` prepares arguments for
Expand All @@ -18,12 +18,12 @@
#'
#' @return
#'
#' `.check_args_epidemic_vacamole()` invisibly returns the model arguments
#' `.check_args_model_vacamole()` invisibly returns the model arguments
#' passed in `mod_args`. If the model arguments did not previously contain
#' elements named `intervention` this is added as dummy objects of the
#' corresponding classes.
#'
#' `.prepare_args_epidemic_vacamole()` returns a list of model arguments
#' `.prepare_args_model_vacamole()` returns a list of model arguments
#' suitable for [.model_vacamole_cpp()]. This is a named list consisting of:
#'
#' - `initial_state`: the initial conditions modified to represent absolute
Expand Down Expand Up @@ -65,7 +65,7 @@
#' is incremented.
#'
#' @keywords internal
.check_args_epidemic_vacamole <- function(mod_args) {
.check_args_model_vacamole <- function(mod_args) {
# check that arguments list has expected names
checkmate::assert_names(
names(mod_args),
Expand Down Expand Up @@ -172,7 +172,7 @@
#' @name check_prepare_vacamole_args
#' @rdname check_prepare_vacamole_args
#' @keywords internal
.prepare_args_epidemic_vacamole <- function(mod_args) {
.prepare_args_model_vacamole <- function(mod_args) {
# prepare the contact matrix and the initial conditions
# scale the contact matrix by the maximum real eigenvalue
contact_matrix <- get_parameter(mod_args[["population"]], "contact_matrix")
Expand Down
8 changes: 4 additions & 4 deletions R/model_default.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ model_default_cpp <- function(population,
# prepare checked arguments for function
# this necessary as check_args adds intervention and vaccination
# if missing
model_arguments <- .prepare_args_epidemic_default(
.check_args_epidemic_default(model_arguments)
model_arguments <- .prepare_args_model_default(
.check_args_model_default(model_arguments)
)

# get compartment names
Expand Down Expand Up @@ -272,8 +272,8 @@ model_default_r <- function(population,
# prepare checked arguments for function
# this necessary as check_args adds intervention and vaccination
# if missing
model_arguments <- .prepare_args_epidemic_default(
.check_args_epidemic_default(model_arguments)
model_arguments <- .prepare_args_model_default(
.check_args_model_default(model_arguments)
)

# get compartment names
Expand Down
4 changes: 2 additions & 2 deletions R/model_ebola.R
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ model_ebola_cpp <- function(population, infection,
# prepare checked arguments for function
# this necessary as check_args adds intervention and vaccination
# if missing
model_arguments <- .prepare_args_epidemic_ebola(
.check_args_epidemic_ebola(model_arguments)
model_arguments <- .prepare_args_model_ebola(
.check_args_model_ebola(model_arguments)
)

# get compartment names
Expand Down
32 changes: 16 additions & 16 deletions R/model_vacamole.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@
#'
#' @export
model_vacamole_cpp <- function(population,
infection,
intervention = NULL,
vaccination,
time_dependence = NULL,
time_end = 100,
increment = 1) {
infection,
intervention = NULL,
vaccination,
time_dependence = NULL,
time_end = 100,
increment = 1) {
# check class on required inputs
checkmate::assert_class(population, "population")
checkmate::assert_class(infection, "infection")
Expand Down Expand Up @@ -157,8 +157,8 @@ model_vacamole_cpp <- function(population,
# prepare checked arguments for function
# this necessary as check_args adds intervention and vaccination
# if missing
model_arguments <- .prepare_args_epidemic_vacamole(
.check_args_epidemic_vacamole(model_arguments)
model_arguments <- .prepare_args_model_vacamole(
.check_args_model_vacamole(model_arguments)
)

# get compartment names
Expand Down Expand Up @@ -296,12 +296,12 @@ model_vacamole_cpp <- function(population,
#'
#' @export
model_vacamole_r <- function(population,
infection,
intervention = NULL,
vaccination,
time_dependence = NULL,
time_end = 100,
increment = 1) {
infection,
intervention = NULL,
vaccination,
time_dependence = NULL,
time_end = 100,
increment = 1) {
# check class on required inputs
checkmate::assert_class(population, "population")
checkmate::assert_class(infection, "infection")
Expand Down Expand Up @@ -345,8 +345,8 @@ model_vacamole_r <- function(population,
# prepare checked arguments for function
# this necessary as check_args adds intervention and vaccination
# if missing
model_arguments <- .prepare_args_epidemic_vacamole(
.check_args_epidemic_vacamole(model_arguments)
model_arguments <- .prepare_args_model_vacamole(
.check_args_model_vacamole(model_arguments)
)

# get compartment names
Expand Down
14 changes: 7 additions & 7 deletions man/check_prepare_default_args.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions man/check_prepare_ebola_args.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions man/check_prepare_vacamole_args.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f07c996

Please sign in to comment.