Skip to content

Commit

Permalink
fix: some borked tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dshemetov committed Oct 4, 2024
1 parent 42ea8ff commit 6165a89
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
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

0 comments on commit 6165a89

Please sign in to comment.