Skip to content

Commit

Permalink
Simplify input checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisaloo authored and joshwlambert committed Jun 10, 2024
1 parent c9c84c4 commit fe2dfb4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions R/extract_param.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fe2dfb4

Please sign in to comment.