From 3049589bc94961d0fb80a0fe6db01d1f44605443 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 11 Oct 2024 09:15:51 +0200 Subject: [PATCH 1/2] better clauses --- R/bounds.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/bounds.R b/R/bounds.R index 01160258..b741942f 100644 --- a/R/bounds.R +++ b/R/bounds.R @@ -368,7 +368,7 @@ zero_range <- function(x, tol = 1000 * .Machine$double.eps) { return(TRUE) } if (length(x) != 2) cli::cli_abort("{.arg x} must be length 1 or 2") - if (any(is.na(x))) { + if (anyNA(x)) { return(NA) } @@ -378,8 +378,8 @@ zero_range <- function(x, tol = 1000 * .Machine$double.eps) { return(TRUE) } - # If we reach this, then x must be (-Inf, Inf) or (Inf, -Inf) - if (all(is.infinite(x))) { + # If we reach this, then x must be (-Inf, ) or (, Inf) + if (any(is.infinite(x))) { return(FALSE) } From 60f846cd68779384b5e7f84cb28e709581e80d79 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 11 Oct 2024 09:16:09 +0200 Subject: [PATCH 2/2] before doing maths, convert to numeric --- R/bounds.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/bounds.R b/R/bounds.R index b741942f..76a4e4a1 100644 --- a/R/bounds.R +++ b/R/bounds.R @@ -385,6 +385,7 @@ zero_range <- function(x, tol = 1000 * .Machine$double.eps) { # Take the smaller (in magnitude) value of x, and use it as the scaling # factor. + x <- as.numeric(unclass(x)) m <- min(abs(x)) # If we get here, then exactly one of the x's is 0. Return FALSE