Skip to content

Commit

Permalink
integration tests and minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Aug 15, 2024
1 parent fa7d2f4 commit ecf8965
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
15 changes: 9 additions & 6 deletions R/create.R
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,15 @@ create_initial_conditions <- function(data) {
meanlog = data$ls_meanlog,
sdlog = ifelse(data$ls_sdlog > 0, data$ls_sdlog, 0.01)
))

out$rescaled_rho <- array(data.table::fcase(
out$rescaled_rho > data$ls_max, data$ls_max - 0.001,
out$rescaled_rho < data$ls_min, data$ls_min + 0.001,
default = out$rescaled_rho
))
if (data$gp_type != 3) {
out$rescaled_rho <- array(data.table::fcase(
out$rescaled_rho > data$ls_max, data$ls_max - 0.001,
out$rescaled_rho < data$ls_min, data$ls_min + 0.001,
default = out$rescaled_rho
))
}else{

Check warning on line 624 in R/create.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/create.R,line=624,col=12,[brace_linter] There should be a space before an opening curly brace.
out$rescaled_rho <- array(numeric(0))
}

out$alpha <- array(
truncnorm::rtruncnorm(
Expand Down
2 changes: 1 addition & 1 deletion inst/stan/estimate_infections.stan
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ generated quantities {
vector[fixed ? 0 : 1] rho;

profile("generated quantities") {
if (!fixed) {
if (!fixed && gp_type != 3) {
vector[noise_terms] x = linspaced_vector(noise_terms, 1, noise_terms);
rho[1] = rescaled_rho[1] * sd(x);
}
Expand Down
15 changes: 14 additions & 1 deletion tests/testthat/test-estimate_infections.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ test_that("estimate_infections successfully returns estimates using default sett
test_estimate_infections(reported_cases)
})

test_that("estimate_infections successfully returns estimates using a Matern 5/2 kernel", {
skip_on_cran()
test_estimate_infections(
reported_cases, gp = gp_opts(kernel = "matern", matern_order = 5 / 2)
)
})

test_that("estimate_infections successfully returns estimates using a Linear kernel", {
skip_on_cran()
test_estimate_infections(
reported_cases, gp = gp_opts(kernel = "linear")
)
})

test_that("estimate_infections successfully returns estimates when passed NA values", {
skip_on_cran()
reported_cases_na <- data.table::copy(reported_cases)
Expand Down Expand Up @@ -85,7 +99,6 @@ test_that("estimate_infections successfully returns estimates using a single bre
)
})


test_that("estimate_infections successfully returns estimates using a random walk", {
skip_on_cran()
test_estimate_infections(reported_cases, gp = NULL, rt = rt_opts(rw = 7))
Expand Down

0 comments on commit ecf8965

Please sign in to comment.