From 6805d98ce2e6fd2123c59005e795da2852940a72 Mon Sep 17 00:00:00 2001 From: Dmitry Shemetov Date: Wed, 2 Oct 2024 19:32:08 -0700 Subject: [PATCH] fix: some borked tests --- tests/testthat/_snaps/population_scaling.md | 16 ++++++++++++++++ tests/testthat/_snaps/step_epi_slide.md | 4 ++-- tests/testthat/test-grf_quantiles.R | 2 +- tests/testthat/test-snapshots.R | 6 +++--- 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 tests/testthat/_snaps/population_scaling.md diff --git a/tests/testthat/_snaps/population_scaling.md b/tests/testthat/_snaps/population_scaling.md new file mode 100644 index 000000000..9263e8e1e --- /dev/null +++ b/tests/testthat/_snaps/population_scaling.md @@ -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'. + diff --git a/tests/testthat/_snaps/step_epi_slide.md b/tests/testthat/_snaps/step_epi_slide.md index a4b9d64c8..7493a7fea 100644 --- a/tests/testthat/_snaps/step_epi_slide.md +++ b/tests/testthat/_snaps/step_epi_slide.md @@ -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. --- @@ -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. --- diff --git a/tests/testthat/test-grf_quantiles.R b/tests/testthat/test-grf_quantiles.R index 2570c247d..5bbaed01f 100644 --- a/tests/testthat/test-grf_quantiles.R +++ b/tests/testthat/test-grf_quantiles.R @@ -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 diff --git a/tests/testthat/test-snapshots.R b/tests/testthat/test-snapshots.R index da8635ae0..5af492378 100644 --- a/tests/testthat/test-snapshots.R +++ b/tests/testthat/test-snapshots.R @@ -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", @@ -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", @@ -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) })