diff --git a/R/parameters.R b/R/parameters.R index 6cca62e7..03e03a65 100644 --- a/R/parameters.R +++ b/R/parameters.R @@ -67,7 +67,7 @@ parameters.list <- function(x, ...) { } param_or_na <- function(x) { - inherits(x, "param") | all(is.na(x)) + inherits(x, "param") || all(is.na(x)) } check_list_of_param <- function(x, ..., call = caller_env()) { diff --git a/tests/testthat/test-parameters.R b/tests/testthat/test-parameters.R index 1a0ccd46..aef44ab1 100644 --- a/tests/testthat/test-parameters.R +++ b/tests/testthat/test-parameters.R @@ -31,6 +31,15 @@ test_that("parameters_constr() input checks", { }) }) +test_that("parameters_constr() allows NA instead of param object", { + ab <- c("a", "b") + expect_no_condition( + p <- parameters_constr(ab, ab, ab, ab, ab, object = list(penalty(), NA)) + ) + expect_s3_class_parameters(p) + expect_true(is.na(p$object[[2]])) +}) + test_that("create from param objects", { expect_no_condition(p_1 <- parameters(mtry(), penalty())) expect_s3_class_parameters(p_1)