Skip to content

Commit e882a93

Browse files
committed
fix(test): add seeds to plot_seromodel test
1 parent 11724c7 commit e882a93

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tests/testthat/test-plot_seromodel.R

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ library(purrr)
77
skip_on_cran()
88

99
# Common data ----
10+
set.seed(123)
11+
stan_seed <- "123"
1012
data(veev2012)
1113
serosurvey <- veev2012
1214

1315
suppressWarnings(
1416
seromodel_constant <- fit_seromodel(
1517
serosurvey = serosurvey,
16-
iter = 100
18+
iter = 100,
19+
seed = stan_seed
1720
)
1821
)
1922

@@ -24,7 +27,8 @@ suppressWarnings(
2427
foi_index = get_foi_index(serosurvey, group_size = 20, model_type = "age"),
2528
is_seroreversion = TRUE,
2629
seroreversion_prior = sf_normal(0, 1e-4),
27-
iter = 100
30+
iter = 100,
31+
seed = stan_seed
2832
)
2933
)
3034

@@ -33,9 +37,11 @@ suppressWarnings(
3337
serosurvey = serosurvey,
3438
model_type = "time",
3539
foi_index = get_foi_index(serosurvey, group_size = 10, model_type = "time"),
36-
iter = 100
40+
iter = 100,
41+
seed = stan_seed
3742
)
3843
)
44+
set.seed(Sys.time())
3945

4046
create_prepared_serosurvey <- function(actual_serosurvey) {
4147
prepared_serosurvey <- prepare_serosurvey_for_plot(
@@ -44,6 +50,7 @@ create_prepared_serosurvey <- function(actual_serosurvey) {
4450
return(prepared_serosurvey)
4551
}
4652

53+
4754
# Test plot_serosurvey ----
4855
test_that("plot_serosurvey creates a ggplot with correct structure", {
4956
skip_on_cran()
@@ -81,6 +88,7 @@ test_that("plot_serosurvey creates a ggplot with correct structure", {
8188
expect_lists_equal_with_tolerance(expected_plot, actual_plot)
8289
})
8390

91+
8492
test_that("plot_serosurvey creates a binned ggplot with correct structure", {
8593
bin_step <- 10
8694

@@ -325,8 +333,6 @@ test_that("plot_seromodel creates a ggplot with correct structure", {
325333
})
326334

327335

328-
329-
330336
test_that("plot_seromodel with age foi creates a ggplot with correct structure", {
331337
seromodel <- seromodel_age
332338

@@ -380,9 +386,6 @@ test_that("plot_seromodel with age foi creates a ggplot with correct structure",
380386
})
381387

382388

383-
384-
385-
386389
test_that("plot_seromodel with time foi creates a ggplot with correct structure", {
387390
seromodel <- seromodel_time
388391

@@ -436,9 +439,6 @@ test_that("plot_seromodel with time foi creates a ggplot with correct structure"
436439
})
437440

438441

439-
440-
441-
442442
# Test plot_seroprev_estimates ----
443443
test_that("plot_seroprev_estimates creates a ggplot with correct structure", {
444444
seromodel <- seromodel_constant

0 commit comments

Comments
 (0)