Skip to content

Commit a2190e9

Browse files
fixing interval check in incidence2 objects
1 parent 495639e commit a2190e9

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

R/project.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,10 @@ project.incidence2 <- function(x, R, si, n_sim = 100, n_days = 7,
476476

477477
## checks specific to incidence2 objects
478478
dates <- incidence2::get_dates(x)
479-
interval <- grates::get_n(dates)
480-
if (interval != 1L) {
479+
interval <- incidence2::get_interval_duration(x)
480+
if (any(interval != 1L)) {
481481
msg <- sprintf(
482-
"daily incidence needed, but interval is %d days",
483-
interval
482+
"daily incidence needed"
484483
)
485484
stop(msg)
486485
}

tests/testthat/test_project.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ test_that(
4545
fixed = TRUE)
4646

4747

48+
i <- incidence2::incidence(data.frame(t = c(0, 1, 1, 3, 3, 4)), "t", interval = 2)
49+
msg <- "daily incidence needed"
50+
expect_error(project(i, R = 1), msg)
4851
}
4952
)
5053

0 commit comments

Comments
 (0)