Skip to content

Commit

Permalink
Read same-day parameters (#132)
Browse files Browse the repository at this point in the history
* Read same-day parameters

Previously a same-day as-of date would have erorred as unable to match
a day, rather than correctly reading for the given start date

* Bump NEWS
  • Loading branch information
zsusswein authored Dec 18, 2024
1 parent 639735c commit 0feb10b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CFAEpiNow2Pipeline (development version)

* Read parameters on the same day correctly
* Added function families to documentation
* Renamed file containing diagnostic functions
* Change formatting of metadata values to be atomic.
Expand Down
2 changes: 1 addition & 1 deletion R/parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ read_interval_pmf <- function(path,
WHERE 1=1
AND parameter = ?
AND disease = ?
AND start_date < ? :: DATE
AND start_date <= ? :: DATE
AND (CAST(end_date AS DATE) > ? :: DATE OR end_date IS NULL)
"
parameters <- list(
Expand Down
32 changes: 32 additions & 0 deletions tests/testthat/test-parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,35 @@ test_that("NULL `reference_date` prints in output", {
)
expect_equal(pmf, pmf_df[["value"]][[1]])
})

test_that("Same-day parameter can be read", {
expected <- c(0.8, 0.2)
path <- "test.parquet"
parameter <- "delay"
start_date <- as.Date("2023-01-01")
disease <- "COVID-19"
reference_date <- NA

withr::with_tempdir({
write_sample_parameters_file(
value = expected,
path = path,
disease = disease,
parameter = parameter,
param = parameter,
start_date = start_date,
end_date = NA,
geo_value = NA,
reference_date = reference_date
)

actual <- read_interval_pmf(
path = path,
disease = disease,
as_of_date = start_date,
parameter = parameter
)

expect_equal(actual, expected)
})
})

0 comments on commit 0feb10b

Please sign in to comment.