Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

* `parameters()` and the `grid_*()` functions give more information in the error message when non-parameter objects are passed in (#437).

* `value_validate()`, `encode_unit()`, `get_p()`, `get_log_p()`, `get_n()`, `get_n_frac()`, `get_n_frac_range()`, and `get_batch_sizes()` now enforce empty dots (#439).


# dials 1.4.2

Expand Down
1 change: 1 addition & 0 deletions R/aaa_values.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#' @export
value_validate <- function(object, values, ..., call = caller_env()) {
check_inherits(object, "param")
check_dots_empty()
res <- switch(
object$type,
double = ,
Expand Down
1 change: 1 addition & 0 deletions R/encode_unit.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ encode_unit.quant_param <- function(x, value, direction, original = TRUE, ...) {
#' @rdname encode_unit
#' @export
encode_unit.qual_param <- function(x, value, direction, ...) {
check_dots_empty()
if (has_unknowns(x)) {
cli::cli_abort("The parameter object contains unknowns.")
}
Expand Down
10 changes: 8 additions & 2 deletions R/finalize.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ finalize.default <- function(object, x, force = TRUE, ...) {
get_p <- function(object, x, log_vals = FALSE, ...) {
check_inherits(object, "param")
check_bool(log_vals)
check_dots_empty()

rngs <- range_get(object, original = FALSE)
if (!is_unknown(rngs$upper)) {
Expand Down Expand Up @@ -186,7 +187,8 @@ get_p <- function(object, x, log_vals = FALSE, ...) {
#' @rdname finalize
get_log_p <- function(object, x, ...) {
check_inherits(object, "param")
get_p(object, x, log_vals = TRUE, ...)
check_dots_empty()
get_p(object, x, log_vals = TRUE)
}

#' @export
Expand All @@ -195,6 +197,7 @@ get_n_frac <- function(object, x, log_vals = FALSE, frac = 1 / 3, ...) {
check_inherits(object, "param")
check_bool(log_vals)
check_number_decimal(frac, min = 0, max = 1)
check_dots_empty()

rngs <- range_get(object, original = FALSE)
if (!is_unknown(rngs$upper)) {
Expand Down Expand Up @@ -233,6 +236,7 @@ get_n_frac_range <- function(
check_inherits(object, "param")
check_bool(log_vals)
check_frac_range(frac)
check_dots_empty()

rngs <- range_get(object, original = FALSE)
if (!is_unknown(rngs$upper)) {
Expand Down Expand Up @@ -265,7 +269,8 @@ get_n_frac_range <- function(
#' @rdname finalize
get_n <- function(object, x, log_vals = FALSE, ...) {
check_inherits(object, "param")
get_n_frac(object, x, log_vals, frac = 1, ...)
check_dots_empty()
get_n_frac(object, x, log_vals, frac = 1)
}

#' @export
Expand Down Expand Up @@ -294,6 +299,7 @@ get_rbf_range <- function(object, x, seed = sample.int(10^5, 1), ...) {
#' @export
get_batch_sizes <- function(object, x, frac = c(1 / 10, 1 / 3), ...) {
lifecycle::deprecate_warn("1.4.2", "get_batch_sizes()")
check_dots_empty()

rngs <- range_get(object, original = FALSE)
if (!is_unknown(rngs$lower) & !is_unknown(rngs$upper)) {
Expand Down
20 changes: 14 additions & 6 deletions R/space_filling.R
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,13 @@ make_max_entropy_grid <- function(
sf_grid <- map2(
params,
sf_grid,
encode_unit,
direction = "backward",
original = original
\(param, grid) {
if (inherits(param, "quant_param")) {
encode_unit(param, grid, direction = "backward", original = original)
} else {
encode_unit(param, grid, direction = "backward")
}
}
)
names(sf_grid) <- param_names
as_tibble(sf_grid)
Expand Down Expand Up @@ -566,9 +570,13 @@ make_latin_hypercube_grid <- function(
sf_grid <- map2(
params,
sf_grid,
encode_unit,
direction = "backward",
original = original
\(param, grid) {
if (inherits(param, "quant_param")) {
encode_unit(param, grid, direction = "backward", original = original)
} else {
encode_unit(param, grid, direction = "backward")
}
}
)
names(sf_grid) <- param_names
as_tibble(sf_grid)
Expand Down
Loading