tests/testthat/test-enw_nowcast_samples.R

test_that("enw_nowcast_samples can extract nowcast samples as expected", {
  fit <- enw_example("nowcast")
  expect_snapshot(
    round_numerics(
      enw_nowcast_samples(
        fit$fit[[1]], fit$latest[[1]],
        max_delay = fit$max_delay
      )[1:10]
    )
  )
})

test_that(paste(
  "enw_nowcast_samples can extract nowcast samples as expected",
  "when a delay larger than modelled is specified"
), {
  fit <- enw_example("nowcast")
  expect_snapshot(
    round_numerics(
      enw_nowcast_samples(
        fit$fit[[1]], fit$latest[[1]], max_delay = 22
      )[c(1:10, 1001:1010, 2001:2010)]
    )
  )
})

test_that(
  "enw_nowcast_samples throws error when max_delay shorter than modeled",
  {
    fit <- enw_example("nowcast")
    expect_error(
      enw_nowcast_samples(
        fit$fit[[1]], fit$latest[[1]], max_delay = fit$max_delay - 1
      ),
      "specified maximum delay must be equal to or larger than the modeled"
    )
  }
)
seabbs/epinowcast documentation built on Oct. 8, 2024, 8:35 p.m.