From 398549db6c858b599d0c69da9643c77cce5ec635 Mon Sep 17 00:00:00 2001 From: Hugo Gruson <10783929+Bisaloo@users.noreply.github.com> Date: Fri, 7 Jun 2024 12:53:46 +0200 Subject: [PATCH] Simplify input checking --- R/extract_param.R | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/R/extract_param.R b/R/extract_param.R index c8c1e6dd4..19fa8f2c8 100644 --- a/R/extract_param.R +++ b/R/extract_param.R @@ -118,16 +118,18 @@ extract_param <- function(type = c("percentiles", "range"), ) # Validate inputs - switch(type, - percentiles = stopifnot( # nolint consecutive_assertion_linter + if (type == "percentiles") { + stopifnot( "'values' and 'percentiles' need to be a vector of length 2" = - type == "percentiles" && length(values) == 2 || length(percentiles) == 2 - ), - range = stopifnot( + length(values) == 2 || length(percentiles) == 2 + ) + } + if (type == "range") { + stopifnot( "'values need to be a vector of length 3" = - type == "range" && length(values) == 3 + length(values) == 3 ) - ) + } # initialise for the loop optim_conv <- FALSE