Skip to content

Commit

Permalink
Merge branch 'main' into 40-queuing_off-should-give-warning-if-the-mo…
Browse files Browse the repository at this point in the history
…del-doesnt-have-a-queue
  • Loading branch information
apulsipher authored Dec 10, 2024
2 parents fa6c212 + 70f48d5 commit 52ff96f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions R/plot_epi.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ plot_epi.epiworld_model <- function(
counts_scale,
...
) {
# Check if model has been run
if (length(get_hist_total(x)$counts) <= 0)
stop("The model must be run before it can be plotted.")

plot_epi(
x = get_hist_total(x),
Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/test-seir.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ expect_silent(agents_smallworld(
expect_silent(verbose_off(seir_0))
expect_silent(queuing_off(seir_0))
expect_silent(initial_states(seir_0, c(.3, .5)))
expect_warning(expect_error(plot(seir_0))) # Plot fails before model is run
expect_error(plot(seir_0), "model must be run before it can be plotted")
expect_silent(run(seir_0, ndays = 100, seed = 1231))
expect_silent(plot(seir_0)) # Plot succeeds after model is run

Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/test-sir.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ expect_silent(agents_smallworld(

# Check model run with queuing -------------------------------------------------
expect_silent(verbose_off(sir_0))
expect_warning(expect_error(plot(sir_0))) # Plot fails before model is run
expect_error(plot(sir_0), "model must be run before it can be plotted")
expect_silent(run(sir_0, ndays = 50, seed = 1912))
expect_silent(plot(sir_0)) # Plot succeeds after model is run

Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/test-sirconn.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ expect_length(class(sirconn_0), 2)
# Check model run with queuing -------------------------------------------------
expect_silent(verbose_off(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_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 Down
2 changes: 1 addition & 1 deletion inst/tinytest/test-sird.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ expect_silent(agents_smallworld(
# Check model run --------------------------------------------------------------
expect_silent(verbose_off(sird_0))
expect_silent(initial_states(sird_0, c(.05, .05)))
expect_warning(expect_error(plot(sird_0))) # Plot fails before model is run
expect_error(plot(sird_0), "model must be run before it can be plotted")
expect_silent(run(sird_0, ndays = 100, seed = 1231))
expect_silent(plot(sird_0)) # Plot succeeds after model is run

Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/test-sis.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ expect_silent(agents_smallworld(

# Check model run --------------------------------------------------------------
expect_silent(verbose_off(sis_0))
expect_warning(expect_error(plot(sis_0))) # Plot fails before model is run
expect_error(plot(sis_0), "model must be run before it can be plotted")
expect_silent(run_multiple(
sis_0,
ndays=100,
Expand Down

0 comments on commit 52ff96f

Please sign in to comment.