Skip to content

Commit

Permalink
queuing_off() should give warning if the model doesn't have a queue (
Browse files Browse the repository at this point in the history
…#54)

* Add warning to queuing_off for SIRCONN and SEIRCONN which have no queue

* Add queuing_off changes to NAMESPACE

* Update test-sirconn.R to cover new queuing_off warning
  • Loading branch information
apulsipher authored Dec 10, 2024
1 parent 70f48d5 commit 6c6568d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ S3method(print,epiworld_tool_fun)
S3method(print,epiworld_virus)
S3method(print,epiworld_virus_fun)
S3method(queuing_off,epiworld_model)
S3method(queuing_off,epiworld_seirconn)
S3method(queuing_off,epiworld_sirconn)
S3method(queuing_on,epiworld_model)
S3method(queuing_on,epiworld_seirconn)
S3method(queuing_on,epiworld_sirconn)
Expand Down
12 changes: 12 additions & 0 deletions R/model-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ queuing_on.epiworld_model <- function(x) {
#' @export
queuing_off <- function(x) UseMethod("queuing_off")

#' @export
queuing_off.epiworld_sirconn <- function(x) {
warning("SIR Connected models do not have queue.")
invisible(x)
}

#' @export
queuing_off.epiworld_seirconn <- function(x) {
warning("SEIR Connected models do not have queue.")
invisible(x)
}

#' @export
queuing_off.epiworld_model <- function(x) {
invisible(queuing_off_cpp(x))
Expand Down
4 changes: 2 additions & 2 deletions inst/tinytest/test-sirconn.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ expect_length(class(sirconn_0), 2)

# Check model run with queuing -------------------------------------------------
expect_silent(verbose_off(sirconn_0))
expect_warning(queuing_on(sirconn_0))
expect_warning(queuing_on(sirconn_0), "SIR Connected models do not have queue.")
expect_error(plot(sirconn_0), "model must be run before it can be plotted")
expect_silent(run(sirconn_0, ndays = 100, seed = 131))
expect_silent(plot(sirconn_0)) # Plot succeeds after model is run
Expand All @@ -51,7 +51,7 @@ tmat_queuing <- get_transition_probability(sirconn_0)
test_tmat(tmat_queuing)

# Check model run without queuing ----------------------------------------------
expect_silent(queuing_off(sirconn_0))
expect_warning(queuing_off(sirconn_0), "SIR Connected models do not have queue.")
run(sirconn_0, ndays = 100, seed = 131)

hist_noqueuing <- get_hist_total(sirconn_0)
Expand Down

0 comments on commit 6c6568d

Please sign in to comment.