Skip to content

Commit 2919395

Browse files
authored
Merge branch 'main' into respect-inclusive-347
2 parents e5e2b23 + da8400f commit 2919395

File tree

8 files changed

+54
-29
lines changed

8 files changed

+54
-29
lines changed

NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313

1414
* `value_seq()` and `value_sample()` now respect the `inclusive` argument of quantitative parameters (#347).
1515

16+
* The constructors, `new_*_parameter()`, now label unlabeled parameter (i.e., constructed with `label = NULL`) as such (#349).
17+
1618
## Breaking changes
1719

1820
* The `grid_*()` functions now error instead of warn when provided with the wrong argument to control the grid size. So `grid_space_filling()`, `grid_random()`, `grid_max_entropy()`, and `grid_latin_hypercube()` now error if used with a `levels` argument and `grid_regular()` now errors if used with a `size` argument (#368).
1921

22+
* The `"optimal"` option for the `weight_func()` parameter has been removed since it is choosing the optimal value based on the resubstition error (#370).
23+
2024
* When constructing integer-valued parameters with a range of two consecutive values the `inclusive` argument needs to be set to `c(TRUE, TRUE)` to leave at least two values to sample from (#373).
2125

2226

R/constructors.R

+36-20
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
#' If set, these will be used by [value_seq()] and [value_sample()].
3333
#'
3434
#' @param label An optional named character string that can be used for
35-
#' printing and plotting. The name should match the object name (e.g.
36-
#' `"mtry"`, `"neighbors"`, etc.)
35+
#' printing and plotting. The name of the label should match the object name
36+
#' (e.g., `"mtry"`, `"neighbors"`, etc.). If `NULL`, the parameter will be
37+
#' labeled with `"Unlabeled parameter"`.
3738
#'
3839
#' @param finalize A function that can be used to set the data-specific
3940
#' values of a parameter (such as the `range`).
@@ -76,16 +77,18 @@ NULL
7677

7778
#' @export
7879
#' @rdname new-param
79-
new_quant_param <- function(type = c("double", "integer"),
80-
range = NULL,
81-
inclusive = NULL,
82-
default = deprecated(),
83-
trans = NULL,
84-
values = NULL,
85-
label = NULL,
86-
finalize = NULL,
87-
...,
88-
call = caller_env()) {
80+
new_quant_param <- function(
81+
type = c("double", "integer"),
82+
range = NULL,
83+
inclusive = NULL,
84+
default = deprecated(),
85+
trans = NULL,
86+
values = NULL,
87+
label = NULL,
88+
finalize = NULL,
89+
...,
90+
call = caller_env()
91+
) {
8992
if (lifecycle::is_present(default)) {
9093
lifecycle::deprecate_stop(
9194
when = "1.1.0",
@@ -156,6 +159,11 @@ new_quant_param <- function(type = c("double", "integer"),
156159
}
157160

158161
check_label(label, call = call)
162+
if (is.null(label)) {
163+
label = "Unlabeled parameter"
164+
names(label) <- "Unlabeled parameter"
165+
}
166+
159167
check_function(finalize, allow_null = TRUE, call = call)
160168

161169
names(range) <- names(inclusive) <- c("lower", "upper")
@@ -189,16 +197,18 @@ new_quant_param <- function(type = c("double", "integer"),
189197

190198
#' @export
191199
#' @rdname new-param
192-
new_qual_param <- function(type = c("character", "logical"),
193-
values,
194-
default = deprecated(),
195-
label = NULL,
196-
finalize = NULL,
197-
...,
198-
call = caller_env()) {
200+
new_qual_param <- function(
201+
type = c("character", "logical"),
202+
values,
203+
default = deprecated(),
204+
label = NULL,
205+
finalize = NULL,
206+
...,
207+
call = caller_env()
208+
) {
199209
if (lifecycle::is_present(default)) {
200210
lifecycle::deprecate_stop(
201-
when = "1.1.0",
211+
when = "1.1.0",
202212
what = "new_qual_param(default)"
203213
)
204214
}
@@ -210,7 +220,13 @@ new_qual_param <- function(type = c("character", "logical"),
210220
"logical" = check_logical(values, call = call),
211221
"character" = check_character(values, call = call)
212222
)
223+
213224
check_label(label, call = call)
225+
if (is.null(label)) {
226+
label = "Unlabeled parameter"
227+
names(label) <- "Unlabeled parameter"
228+
}
229+
214230
check_function(finalize, allow_null = TRUE, call = call)
215231

216232
res <- list(

R/param_activation.R

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ activation_2 <- function(values = values_activation) {
3131

3232
#' @rdname activation
3333
#' @export
34-
values_activation <- c("linear", "softmax", "relu", "elu", "tanh")
34+
values_activation <- c("celu", "elu", "exponential", "gelu", "hardshrink",
35+
"hardsigmoid", "hardtanh", "leaky_relu", "linear", "log_sigmoid", "relu",
36+
"relu6", "rrelu", "selu", "sigmoid", "silu", "softmax", "softplus",
37+
"softshrink", "softsign", "swish", "tanh", "tanhshrink"
38+
)
39+
# sort(unique(c(brulee::brulee_activations(), parsnip::keras_activations())))

R/param_weight_func.R

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,5 @@ values_weight_func <- c(
2929
"cos",
3030
"inv",
3131
"gaussian",
32-
"rank",
33-
"optimal"
32+
"rank"
3433
)

man/activation.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/new-param.Rd

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/weight_func.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/constructors.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@
205205
print(fun_ish)
206206
Message
207207
Qualitative Parameter
208-
10 possible values include:
208+
9 possible values include:
209209
'rectangular', 'triangular', 'epanechnikov', 'biweight', 'triweight', 'cos',
210-
'inv', 'gaussian', 'rank', and 'optimal'
210+
'inv', 'gaussian', and 'rank'
211211

212212
---
213213

0 commit comments

Comments
 (0)