Skip to content

Commit 67fb0b4

Browse files
authored
Merge pull request #58 from cmu-delphi/lists_of_realFix
fix: included NA's in lists_of_real_values
2 parents 9da2783 + bb44f96 commit 67fb0b4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

R/targets_utils.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ make_target_param_grid <- function(param_grid) {
2323
lists_of_real_values <- function(param_grid) {
2424
full_lists <- transpose(param_grid %>% select(-forecaster, -id))
2525
filter_nonvalues <- function(x) {
26-
Filter(Negate(function(a) is.null(a) && is.na(a)), x)
26+
Filter(Negate(function(a) is.null(a) || is.na(a)), x)
2727
}
2828
map(full_lists, filter_nonvalues)
2929
}

tests/testthat/test-target-utils.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
test_that("target param generation works", {
2+
ex_frame <- tribble(
3+
~forecaster, ~id, ~someNAs, ~someNULLs,
4+
"scaled_pop", "linreg", TRUE, 35,
5+
"scaled_pop", "linreg", NA, 35,
6+
"scaled_pop", "linreg", FALSE, NULL,
7+
)
8+
list_version <- list(
9+
list(someNAs = TRUE, someNULLs = 35),
10+
list(someNULLs = 35),
11+
list(someNAs = FALSE)
12+
)
13+
expect_equal(lists_of_real_values(ex_frame), list_version)
14+
})

0 commit comments

Comments
 (0)