Skip to content

Commit 0961ecd

Browse files
authored
Merge pull request #21 from kenmawer/km-issue_27
Km issue 27 tests
2 parents 877edb7 + 45c5ab6 commit 0961ecd

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

musings/example-recipe.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ r <- epi_recipe(x) %>% # if we add this as a class, maybe we get better
4040
step_epi_ahead(death_rate, ahead = 7) %>%
4141
step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
4242
step_epi_lag(case_rate, lag = c(0, 7, 14)) %>%
43-
step_narm()
43+
step_naomit2()
4444

4545

4646
slm <- linear_reg()

tests/testthat/test-step_naomit2.R

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
library(dplyr)
2+
library(epiprocess)
3+
library(parsnip)
4+
library(workflows)
5+
6+
# Random generated dataset
7+
set.seed(100)
8+
x <- tibble(geo_value = rep("nowhere",200),
9+
time_value = as.Date("2021-01-01") + 0:199,
10+
case_rate = rpois(100,20) + 1:200,
11+
death_rate = rpois(100,10) + 1:200) %>%
12+
as_epi_df()
13+
14+
r <- epi_recipe(x) %>%
15+
step_epi_ahead(death_rate, ahead = 7) %>%
16+
step_epi_lag(death_rate, lag = c(0,7,14))
17+
18+
extract <- function(recipe) {
19+
recipe
20+
}
21+
22+
z1 <- step_naomit2(r)
23+
z2 <- r %>%
24+
step_naomit(all_predictors()) %>%
25+
step_naomit(all_outcomes(), skip = TRUE)
26+
27+
# Tests
28+
test_that("Check that both functions behave the same way", {
29+
expect_identical(z1$steps[[3]][-1][-5],z2$steps[[3]][-1][-5])
30+
expect_identical(z1$steps[[4]][-1][-5],z2$steps[[4]][-1][-5])
31+
expect_identical(class(z1$steps[[3]]),class(z2$steps[[3]]))
32+
expect_identical(class(z1$steps[[4]]),class(z2$steps[[4]]))
33+
})

0 commit comments

Comments
 (0)