From ac219e06e196539ec19705049ec6a8d97e711806 Mon Sep 17 00:00:00 2001 From: Hannah Frick Date: Tue, 2 Sep 2025 21:20:03 +0100 Subject: [PATCH] tweak `inclusive` based on `range` --- NEWS.md | 3 +++ R/param_range_limits.R | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 5ae5e18b..56d646c0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,9 @@ * `prop_terms()` is a new parameter object used for recipes that do supervised feature selection (#395). +* `upper_limit()` and `lower_limit()` now have ranges that are inclusive of the endpoints, unless the endpoint is infinite (#396). + + # dials 1.4.1 * Two new parameters, `cal_method_class()` and `cal_method_reg(),` to control which method is used to calibrate model predictions (#383). diff --git a/R/param_range_limits.R b/R/param_range_limits.R index 9b759531..b1571c9b 100644 --- a/R/param_range_limits.R +++ b/R/param_range_limits.R @@ -13,10 +13,13 @@ #' @rdname range_limits #' @export lower_limit <- function(range = c(-Inf, Inf), trans = NULL) { + inclusive <- c(TRUE, TRUE) + inclusive[is.infinite(range)] <- FALSE + new_quant_param( type = "double", range = range, - inclusive = c(TRUE, FALSE), + inclusive = inclusive, trans = trans, label = c(lower_limit = "Lower Limit"), finalize = NULL @@ -26,10 +29,13 @@ lower_limit <- function(range = c(-Inf, Inf), trans = NULL) { #' @rdname range_limits #' @export upper_limit <- function(range = c(-Inf, Inf), trans = NULL) { + inclusive <- c(TRUE, TRUE) + inclusive[is.infinite(range)] <- FALSE + new_quant_param( type = "double", range = range, - inclusive = c(FALSE, TRUE), + inclusive = inclusive, trans = trans, label = c(upper_limit = "Upper Limit"), finalize = NULL