From e41e58a204d7f79858ea4e238470801e2d355679 Mon Sep 17 00:00:00 2001 From: pqiao29 <pqiao@student.unimelb.edu.au> Date: Thu, 16 Apr 2020 18:55:24 +1000 Subject: [PATCH] change I,Q,H->R to I,Q->R --- R/FIN_plot.R | 2 +- R/MOD_recovery.R | 2 +- R/original_plot_models.R | 4 ++-- tests/testthat/.DS_Store | Bin 6148 -> 6148 bytes tests/testthat/test-all-modules.R | 28 ---------------------- tests/testthat/test-recovery.R | 23 ------------------ tests/testthat/test-seiqhrf-simulate.R | 32 ------------------------- 7 files changed, 4 insertions(+), 87 deletions(-) delete mode 100644 tests/testthat/test-all-modules.R delete mode 100644 tests/testthat/test-recovery.R delete mode 100644 tests/testthat/test-seiqhrf-simulate.R diff --git a/R/FIN_plot.R b/R/FIN_plot.R index 508b8a6..6c46abf 100644 --- a/R/FIN_plot.R +++ b/R/FIN_plot.R @@ -213,7 +213,7 @@ plot_sirplus <- function(x, comp_remove, theme_bw() + theme(axis.text.x = element_text(angle = 90)) if(length(unique(plot_df$experiment)) > 1){ - p <- p + facet_grid(reo_exp(experiment) ~ ., scale = 'free') + p <- p + facet_grid(reo_exp(experiment) ~ ., scales = 'free') } if(sep_compartments){ diff --git a/R/MOD_recovery.R b/R/MOD_recovery.R index dfce50a..5d93feb 100644 --- a/R/MOD_recovery.R +++ b/R/MOD_recovery.R @@ -114,7 +114,7 @@ recovery.FUN <- function(dat, at, seed = NULL) { rand = dat$control$rec.rand, active, status = dat$attr$status, - label = c("i", "q", "h"), + label = c("i", "q"), state = recovState, at, expTime = dat$attr$expTime, diff --git a/R/original_plot_models.R b/R/original_plot_models.R index 049b888..016b614 100644 --- a/R/original_plot_models.R +++ b/R/original_plot_models.R @@ -87,7 +87,7 @@ plot_models <- function(sims = baseline_sim, } else ( plot_df %>% ggplot(aes(x = Date, y = count, colour = compartment, linetype = sim)) + - facet_grid(reo_exp(experiment) ~ ., scale = 'free') + + facet_grid(reo_exp(experiment) ~ ., scales = 'free') + scale_x_date(date_breaks = "1 week", date_labels = "%m-%d") + geom_line(size = 1.5, alpha = 0.8) + scale_colour_manual(values = compcols, labels = complabels) + @@ -109,7 +109,7 @@ plot_models <- function(sims = baseline_sim, } else ( plot_df %>% ggplot(aes(x = Date, y = count+1, colour = compartment, linetype = sim)) + - facet_grid(reo_exp(experiment) ~ ., scale = 'free') + + facet_grid(reo_exp(experiment) ~ ., scales = 'free') + scale_y_continuous(trans = trans) + scale_x_date(date_breaks = "1 week", date_labels = "%m-%d") + geom_line(size = 1.5, alpha = 0.8) + diff --git a/tests/testthat/.DS_Store b/tests/testthat/.DS_Store index c75274b698af4eb48b88f2e123d3eb21760bb0ce..83ee8de8d1227601f3384dd2fcf93d92c9374316 100644 GIT binary patch delta 53 zcmZoMXfc@JFUrEez`)4BAi%(&%aF)W1caFkWt$%|FK1+A*&M*c%DDL%vm(pHhO3*| IIsWnk05K5_hX4Qo delta 255 zcmZoMXfc@JFUroqz`)4BAi%(&%aF*B1BAK^xtj%<movJ8q=Xns7*ZLEfh3YNLq0<a zLn%-xNJft#$TKHDIVmSU38)@u4udiftN#ZB28PW%OstIc{7A+W0ktIqjVJ@sMGTdg z2C!U4HUP*LN77vk)RoCl$dCcln+9}LF_4!Fc1$8z6^3(IXEQKxz}y4$m^RC1c8<UN E0N*V=u>b%7 diff --git a/tests/testthat/test-all-modules.R b/tests/testthat/test-all-modules.R deleted file mode 100644 index 1c7107f..0000000 --- a/tests/testthat/test-all-modules.R +++ /dev/null @@ -1,28 +0,0 @@ -test_that("All modules(MOD) produce the same result as Churches' modules (.seiqhrf.icm)", { - - param <- param_seiqhrf(arec.rate = 0) - init <- init_seiqhrf(s.num = 1000) - - #### default functions: initialize.FUN, infection.FUN, recovery.FUN, departures.FUN, arrivals.FUN - control1 <- control_seiqhrf(nsteps = 10) - ### Churches' original function: - control2 <- control1 - control2$initialize.FUN <- "initialize.icm" - control2$infection.FUN <- "infection.seiqhrf.icm" - control2$recovery.FUN <- "progress.seiqhrf.icm" - control2$departures.FUN <- "departures.seiqhrf.icm" - control2$arrivals.FUN <- "arrivals.seiqhrf.icm" - - No_seeds <- 10 - seed_list <- sample(1:1000, No_seeds) - comp <- rep(NA, No_seeds) - i <- 1 - for(seed in seed_list){ - sim1 <- seiqhrf(param = param, init = init, control = control1, seed) - sim2 <- seiqhrf(param = param, init = init, control = control2, seed) - comp[i] <- identical(sim1, sim2) - i <- i + 1 - } - - expect_equal(sum(comp), No_seeds) -}) diff --git a/tests/testthat/test-recovery.R b/tests/testthat/test-recovery.R deleted file mode 100644 index 527a3e3..0000000 --- a/tests/testthat/test-recovery.R +++ /dev/null @@ -1,23 +0,0 @@ -test_that("Identical output as Churches' original function: recovery.FUN", { - - control <- control_seiqhrf() - param <- param_seiqhrf(arec.rate = 0) - init <- init_seiqhrf() - - at <- 2 - dat <- do.call(initialize.FUN, list(param, init, control)) - dat <- do.call(infection.FUN, list(dat, at)) - - No_seeds <- 10 - seed_list <- sample(1:1000, No_seeds) - comp <- rep(NA, No_seeds) - i <- 1 - for(seed in seed_list){ - dat1 <- do.call(recovery.FUN, list(dat, at, seed)) - dat2 <- do.call(progress.seiqhrf.icm, list(dat, at, seed)) - comp[i] <- identical(dat1, dat2) - i <- i + 1 - } - - expect_equal(sum(comp), No_seeds) -}) \ No newline at end of file diff --git a/tests/testthat/test-seiqhrf-simulate.R b/tests/testthat/test-seiqhrf-simulate.R deleted file mode 100644 index 9581007..0000000 --- a/tests/testthat/test-seiqhrf-simulate.R +++ /dev/null @@ -1,32 +0,0 @@ -test_that("seiqhrf and simulate_seiqhrf produce identical output", { - - s.num = 1000 - q.num = 10 - nsteps = 10 - nsims = 3 - arec.rate = 0 ### has to be fixed 0 for comparison - - No_seeds <- 10 - seed_list <- sample(1:1000, No_seeds) - comp <- rep(NA, No_seeds) - i <- 1 - for(seed in seed_list){ - Churhes_res <- simulate_seiqhrf(nsteps = nsteps, nsims = nsims, - arec.rate = arec.rate, s.num = s.num, q.num = q.num, - infection.FUN = infection.seiqhrf.icm, - recovery.FUN = progress.seiqhrf.icm, - departures.FUN = departures.seiqhrf.icm, - arrivals.FUN = arrivals.seiqhrf.icm, seed = seed)$sim - class(Churhes_res) <- "seiqhrf" - - param <- param_seiqhrf(arec.rate = arec.rate) - init <- init_seiqhrf(s.num = s.num, q.num = q.num) - control <- control_seiqhrf(nsteps = nsteps, nsims = nsims) - sirplus_res <- seiqhrf(init, control, param, seed) - - comp[i] <- identical(Churhes_res[3:4], sirplus_res[3:4]) # Due to $usr.specified in control and param, can only compare "epi" and "times - i <- i + 1 - } - - expect_equal(sum(comp), No_seeds) -}) -- GitLab