Skip to content
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ Imports:
vctrs,
workflows (>= 1.0.0)
Suggests:
covidcast,
data.table,
epidatr (>= 1.0.0),
fs,
Expand All @@ -61,6 +60,7 @@ Suggests:
quantreg,
ranger,
RcppRoll,
readr,
rmarkdown,
smoothqr,
testthat (>= 3.0.0),
Expand Down
7 changes: 2 additions & 5 deletions data-raw/case_death_rate_subset.R
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
library(tidyverse)
library(covidcast)
library(epidatr)
library(epiprocess)

x <- covidcast(
x <- pub_covidcast(
data_source = "jhu-csse",
signals = "confirmed_7dav_incidence_prop",
time_type = "day",
geo_type = "state",
time_values = epirange(20201231, 20211231),
geo_values = "*"
) %>%
fetch() %>%
select(geo_value, time_value, case_rate = value)

y <- covidcast(
y <- pub_covidcast(
data_source = "jhu-csse",
signals = "deaths_7dav_incidence_prop",
time_type = "day",
geo_type = "state",
time_values = epirange(20201231, 20211231),
geo_values = "*"
) %>%
fetch() %>%
select(geo_value, time_value, death_rate = value)

case_death_rate_subset <- x %>%
Expand Down
3 changes: 1 addition & 2 deletions data-raw/state_census.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
library(dplyr)
library(tidyr)

state_census <- covidcast::state_census %>%
state_census <- readr::read_csv("https://github.com/cmu-delphi/covidcast/raw/c89e4d295550ba1540d64d2cc991badf63ad04e5/Python-packages/covidcast-py/covidcast/geo_mappings/state_census.csv") %>% # nolint: line_length_linter
select(STATE, NAME, POPESTIMATE2019, ABBR) %>%
rename(abbr = ABBR, name = NAME, pop = POPESTIMATE2019, fips = STATE) %>%
mutate(abbr = tolower(abbr)) %>%
as_tibble()


usethis::use_data(state_census, overwrite = TRUE)
16 changes: 16 additions & 0 deletions tests/testthat/_snaps/population_scaling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# expect error if `by` selector does not match

Code
wf <- epi_workflow(r, parsnip::linear_reg()) %>% fit(jhu) %>% add_frosting(f)
Condition
Error in `hardhat::validate_column_names()`:
! The following required columns are missing: 'a'.

---

Code
forecast(wf)
Condition
Error in `hardhat::validate_column_names()`:
! The following required columns are missing: 'nothere'.

4 changes: 2 additions & 2 deletions tests/testthat/_snaps/step_epi_slide.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
r %>% step_epi_slide(value, .f = mean, .window_size = c(3L, 6L))
Condition
Error in `epiprocess:::validate_slide_window_arg()`:
! Slide function expected `.window_size` to be a non-null, scalar integer >= 1.
! Slide function expected `.window_size` to be a length-1 difftime with units in days or non-negative integer or Inf.

---

Expand Down Expand Up @@ -60,7 +60,7 @@
r %>% step_epi_slide(value, .f = mean, .window_size = 1.5)
Condition
Error in `epiprocess:::validate_slide_window_arg()`:
! Slide function expected `.window_size` to be a difftime with units in days or non-negative integer or Inf.
! Slide function expected `.window_size` to be a length-1 difftime with units in days or non-negative integer or Inf.

---

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-grf_quantiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test_that("quantile_rand_forest defaults work", {
expect_silent(out <- fit(spec, formula = y ~ x + z, data = tib))
pars <- parsnip::extract_fit_engine(out)
manual <- quantile_forest(as.matrix(tib[, 2:3]), tib$y, quantiles = c(0.1, 0.5, 0.9))
expect_identical(pars$quantiles.orig, manual$quantiles)
expect_identical(pars$quantiles.orig, manual$quantiles.orig)
expect_identical(pars$`_num_trees`, manual$`_num_trees`)

fseed <- 12345
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-snapshots.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ test_that("arx_forecaster output format snapshots", {
jhu, "death_rate",
c("case_rate", "death_rate")
)
expect_equal(as.Date(out1$metadata$forecast_created), Sys.Date())
expect_equal(as.Date(format(out1$metadata$forecast_created, "%Y-%m-%d")), Sys.Date())
out1$metadata$forecast_created <- as.Date("0999-01-01")
expect_snapshot(out1)
out2 <- arx_forecaster(jhu, "case_rate",
Expand All @@ -129,7 +129,7 @@ test_that("arx_forecaster output format snapshots", {
forecast_date = as.Date("2022-01-03")
)
)
expect_equal(as.Date(out2$metadata$forecast_created), Sys.Date())
expect_equal(as.Date(format(out2$metadata$forecast_created, "%Y-%m-%d")), Sys.Date())
out2$metadata$forecast_created <- as.Date("0999-01-01")
expect_snapshot(out2)
out3 <- arx_forecaster(jhu, "death_rate",
Expand All @@ -140,7 +140,7 @@ test_that("arx_forecaster output format snapshots", {
forecast_date = as.Date("2022-01-03")
)
)
expect_equal(as.Date(out3$metadata$forecast_created), Sys.Date())
expect_equal(as.Date(format(out3$metadata$forecast_created, "%Y-%m-%d")), Sys.Date())
out3$metadata$forecast_created <- as.Date("0999-01-01")
expect_snapshot(out3)
})
Expand Down
Loading