Skip to content

Commit 4f4e5c0

Browse files
authored
Enforce empty dots (#439)
* enforce empty dots * enforce empty dots
1 parent 55e12cb commit 4f4e5c0

5 files changed

Lines changed: 26 additions & 8 deletions

File tree

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

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

11+
* `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).
12+
1113

1214
# dials 1.4.2
1315

R/aaa_values.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
#' @export
7575
value_validate <- function(object, values, ..., call = caller_env()) {
7676
check_inherits(object, "param")
77+
check_dots_empty()
7778
res <- switch(
7879
object$type,
7980
double = ,

R/encode_unit.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ encode_unit.quant_param <- function(x, value, direction, original = TRUE, ...) {
7070
#' @rdname encode_unit
7171
#' @export
7272
encode_unit.qual_param <- function(x, value, direction, ...) {
73+
check_dots_empty()
7374
if (has_unknowns(x)) {
7475
cli::cli_abort("The parameter object contains unknowns.")
7576
}

R/finalize.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ finalize.default <- function(object, x, force = TRUE, ...) {
156156
get_p <- function(object, x, log_vals = FALSE, ...) {
157157
check_inherits(object, "param")
158158
check_bool(log_vals)
159+
check_dots_empty()
159160

160161
rngs <- range_get(object, original = FALSE)
161162
if (!is_unknown(rngs$upper)) {
@@ -186,7 +187,8 @@ get_p <- function(object, x, log_vals = FALSE, ...) {
186187
#' @rdname finalize
187188
get_log_p <- function(object, x, ...) {
188189
check_inherits(object, "param")
189-
get_p(object, x, log_vals = TRUE, ...)
190+
check_dots_empty()
191+
get_p(object, x, log_vals = TRUE)
190192
}
191193

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

199202
rngs <- range_get(object, original = FALSE)
200203
if (!is_unknown(rngs$upper)) {
@@ -233,6 +236,7 @@ get_n_frac_range <- function(
233236
check_inherits(object, "param")
234237
check_bool(log_vals)
235238
check_frac_range(frac)
239+
check_dots_empty()
236240

237241
rngs <- range_get(object, original = FALSE)
238242
if (!is_unknown(rngs$upper)) {
@@ -265,7 +269,8 @@ get_n_frac_range <- function(
265269
#' @rdname finalize
266270
get_n <- function(object, x, log_vals = FALSE, ...) {
267271
check_inherits(object, "param")
268-
get_n_frac(object, x, log_vals, frac = 1, ...)
272+
check_dots_empty()
273+
get_n_frac(object, x, log_vals, frac = 1)
269274
}
270275

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

298304
rngs <- range_get(object, original = FALSE)
299305
if (!is_unknown(rngs$lower) & !is_unknown(rngs$upper)) {

R/space_filling.R

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,13 @@ make_max_entropy_grid <- function(
493493
sf_grid <- map2(
494494
params,
495495
sf_grid,
496-
encode_unit,
497-
direction = "backward",
498-
original = original
496+
\(param, grid) {
497+
if (inherits(param, "quant_param")) {
498+
encode_unit(param, grid, direction = "backward", original = original)
499+
} else {
500+
encode_unit(param, grid, direction = "backward")
501+
}
502+
}
499503
)
500504
names(sf_grid) <- param_names
501505
as_tibble(sf_grid)
@@ -584,9 +588,13 @@ make_latin_hypercube_grid <- function(
584588
sf_grid <- map2(
585589
params,
586590
sf_grid,
587-
encode_unit,
588-
direction = "backward",
589-
original = original
591+
\(param, grid) {
592+
if (inherits(param, "quant_param")) {
593+
encode_unit(param, grid, direction = "backward", original = original)
594+
} else {
595+
encode_unit(param, grid, direction = "backward")
596+
}
597+
}
590598
)
591599
names(sf_grid) <- param_names
592600
as_tibble(sf_grid)

0 commit comments

Comments
 (0)