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

queuing_off() should give warning if the model doesn't have a queue #54

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
#' @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)

Check warning on line 139 in R/model-methods.R

View check run for this annotation

Codecov / codecov/patch

R/model-methods.R#L138-L139

Added lines #L138 - L139 were not covered by tests
}

#' @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_warning(expect_error(plot(sirconn_0))) # Plot fails before model is run
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
Loading