Skip to content

Commit a8a8e92

Browse files
authored
Merge pull request #433 from tidymodels:parameters_constr-NA
add test on NA behavior
2 parents 44ba2aa + 1934ac3 commit a8a8e92

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

R/parameters.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ parameters.list <- function(x, ...) {
6767
}
6868

6969
param_or_na <- function(x) {
70-
inherits(x, "param") | all(is.na(x))
70+
inherits(x, "param") || all(is.na(x))
7171
}
7272

7373
check_list_of_param <- function(x, ..., call = caller_env()) {

tests/testthat/test-parameters.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ test_that("parameters_constr() input checks", {
3131
})
3232
})
3333

34+
test_that("parameters_constr() allows NA instead of param object", {
35+
ab <- c("a", "b")
36+
expect_no_condition(
37+
p <- parameters_constr(ab, ab, ab, ab, ab, object = list(penalty(), NA))
38+
)
39+
expect_s3_class_parameters(p)
40+
expect_true(is.na(p$object[[2]]))
41+
})
42+
3443
test_that("create from param objects", {
3544
expect_no_condition(p_1 <- parameters(mtry(), penalty()))
3645
expect_s3_class_parameters(p_1)

0 commit comments

Comments
 (0)