Skip to content

qualify internal functions in tests #426

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

Merged
merged 1 commit into from
Jul 18, 2023
Merged
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
qualify internal functions
  • Loading branch information
sbfnk committed Jul 18, 2023
commit ff6307872837cc4a8c711d21313d874ad4422966
2 changes: 1 addition & 1 deletion tests/testthat/test-delays.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ test_stan_delays <- function(generation_time = generation_time_opts(),
delays = delay_opts(),
truncation = trunc_opts(),
params = c()) {
data <- create_stan_delays(
data <- EpiNow2:::create_stan_delays(
generation_time = generation_time,
delays = delays,
truncation = truncation,
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-dist_spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ test_that("Testing `+.dist_spec` function with tolerance parameter", {
)

# Compute combined distribution with default tolerance
combined_default <- `+.dist_spec`(lognormal, gamma)
combined_default <- EpiNow2:::`+.dist_spec`(lognormal, gamma)

# Compute combined distribution with larger tolerance
combined_larger_tolerance <- EpiNow2:::dist_spec_plus(
Expand Down Expand Up @@ -148,21 +148,21 @@ test_that("mean.dist_spec returns correct output for fixed lognormal distributio
mean = convert_to_logmean(3, 1), sd = convert_to_logsd(3, 1),
max = 20, distribution = "lognormal"
)
result <- mean.dist_spec(lognormal)
result <- EpiNow2:::mean.dist_spec(lognormal)
expect_equal(result, 2.49, tolerance = 0.01) # here we can see the bias from
# using this kind of discretisation approach
})

test_that("mean.dist_spec returns correct output for uncertain gamma distribution", {
gamma <- dist_spec(mean = 3, sd = 2, mean_sd = 0.5, sd_sd = 0.5, max = 20, distribution = "gamma")
result <- mean.dist_spec(gamma)
result <- EpiNow2:::mean.dist_spec(gamma)
expect_equal(result, 3)
})

test_that("mean.dist_spec returns correct output for sum of two distributions", {
lognormal <- dist_spec(mean = 1, sd = 1, max = 20, distribution = "lognormal")
gamma <- dist_spec(mean = 3, sd = 2, max = 20, distribution = "gamma")
result <- mean.dist_spec(lognormal + gamma)
result <- EpiNow2:::mean.dist_spec(lognormal + gamma)
expect_equal(result, c(5.84), tolerance = 0.001)
})

Expand Down
12 changes: 8 additions & 4 deletions tests/testthat/test-match_output_arguments.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ test_that("match_output_arguments works as expected", {
out <- rep(FALSE, 3)
names(out) <- c("fit", "plots", "samples")
expect_equal(
match_output_arguments(supported_args = names(out)),
EpiNow2:::match_output_arguments(supported_args = names(out)),
out
)
out["plots"] <- TRUE
expect_equal(match_output_arguments("plots", supported_args = names(out)), out)
expect_equal(
EpiNow2:::match_output_arguments("plots", supported_args = names(out)), out
)
out["samples"] <- TRUE
expect_equal(match_output_arguments(c("plots", "samples"),
expect_equal(EpiNow2:::match_output_arguments(c("plots", "samples"),
supported_args = names(out)
), out)
expect_equal(match_output_arguments("p", supported_args = names(out)), out)
expect_equal(
EpiNow2:::match_output_arguments("p", supported_args = names(out)), out
)
})
10 changes: 7 additions & 3 deletions tests/testthat/test-seeding-time.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ test_that("Seeding times are correctly calculated", {
gt2 <- dist_spec(mean = 10, sd = 2, max = 15)
delay1 <- dist_spec(mean = 5, sd = 1, max = 10)
delay2 <- dist_spec(mean = 7, sd = 3, max = 15)
expect_equal(get_seeding_time(delay1, gt1 + gt2), 23L) ## 10 + 15 - 1 - 1
expect_equal(get_seeding_time(delay1 + delay2, gt1), 12L) ## 5 + 7
expect_equal(
EpiNow2:::get_seeding_time(delay1, gt1 + gt2), 23L ## 10 + 15 - 1 - 1
)
expect_equal(
EpiNow2:::get_seeding_time(delay1 + delay2, gt1), 12L ## 5 + 7
)
})

test_that("Short seeding times are rounded up to 1", {
delay <- dist_spec(mean = 0.5, sd = 1, max = 2)
gt <- dist_spec(mean = 1)
expect_equal(get_seeding_time(delay, gt), 1L)
expect_equal(EpiNow2:::get_seeding_time(delay, gt), 1L)
})