Skip to content

Commit e1f21d1

Browse files
committed
adding a brief test
1 parent ff2a2a9 commit e1f21d1

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

R/layer_residual_quantiles.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,12 @@ slather.layer_residual_quantiles <-
139139

140140
estimate <- components$predictions$.pred
141141
res <- tibble(.pred_distn = r$dstn + estimate)
142-
res <- check_name(res, components$predictions, object, newname = object$name)
142+
res <- check_name(
143+
res,
144+
components$predictions,
145+
object,
146+
newname = object$name
147+
)
143148
components$predictions <- mutate(components$predictions, !!!res)
144149
components
145150
}

tests/testthat/test-layer_residual_quantiles.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ test_that("Returns expected number or rows and columns", {
2828
expect_equal(unique(unnested$.pred_distn_quantile_level), c(.0275, 0.5, .8, .95))
2929
})
3030

31+
tests_that("new name works correctly", {
32+
f <- frosting() %>%
33+
layer_predict() %>%
34+
layer_naomit(.pred) %>%
35+
layer_residual_quantiles(name = "foo")
36+
37+
wf1 <- wf %>% add_frosting(f)
38+
expect_equal(names(forecast(wf1)), c("geo_value", "time_value", ".pred", "foo"))
39+
40+
f <- frosting() %>%
41+
layer_predict() %>%
42+
layer_naomit(.pred) %>%
43+
layer_residual_quantiles(name = "geo_value")
44+
45+
wf1 <- wf %>% add_frosting(f)
46+
expect_error(forecast(wf1))
47+
})
3148

3249
test_that("Errors when used with a classifier", {
3350
tib <- tibble(

0 commit comments

Comments
 (0)