Skip to content

Commit 8f200f3

Browse files
committed
merge
1 parent 88cb475 commit 8f200f3

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

R/new_epipredict_steps/layer_yeo_johnson.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ slather.layer_epi_YeoJohnson <- function(object, components, workflow, new_data,
156156
# c("lambda_ahead_1_case_rate", "lambda_ahead_7_case_rate").
157157
original_outcome_cols <- str_match(col_names, ".pred_ahead_\\d+_(.*)")[, 2]
158158
outcomes_wout_ahead <- str_match(names(components$mold$outcomes), "ahead_\\d+_(.*)")[,2]
159-
if (all(original_outcome_cols %nin% outcomes_wout_ahead)) {
159+
if (any(original_outcome_cols %nin% outcomes_wout_ahead)) {
160160
cli_abort("All columns specified in `...` must be outcome columns.", call = rlang::caller_env())
161161
}
162162

R/new_epipredict_steps/step_yeo_johnson.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ get_lambdas_yj_table <- function(training, col_names, limits, num_unique, na_lam
237237
lambdas <- training %>%
238238
summarise(
239239
across(all_of(col_names), ~ estimate_yj(.x, limits, num_unique, na_rm)),
240-
.by = epi_keys_checked
240+
.by = all_of(epi_keys_checked)
241241
) %>%
242242
rename_with(~ paste0(".lambda_", .x), -all_of(epi_keys_checked))
243243

tests/testthat/test-yeo-johnson.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
suppressPackageStartupMessages(source(here::here("R", "load_all.R")))
22

33
test_that("Yeo-Johnson transformation inverts correctly", {
4+
# Note that the special lambda values of 0 and 2 are covered by the tests
5+
# below.
46
expect_true(
57
map_lgl(seq(-5, 5, 0.1), function(lambda) {
68
map_lgl(seq(-10, 10, 0.1), \(x) abs(yj_inverse(yj_transform(x, lambda), lambda) - x) < 0.00001) %>% all()

0 commit comments

Comments
 (0)