Skip to content

Commit

Permalink
Use rlang arg_match() to prevent partial match
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmbaazam committed Nov 1, 2023
1 parent c277d5c commit d5c3ebb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ importFrom(purrr,safely)
importFrom(purrr,transpose)
importFrom(purrr,walk)
importFrom(rlang,abort)
importFrom(rlang,arg_match)
importFrom(rlang,cnd_muffle)
importFrom(rlang,warn)
importFrom(rstan,expose_stan_functions)
Expand Down
13 changes: 7 additions & 6 deletions R/checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ check_reports_valid <- function(reports, model) {
# Check that the case time series (reports) is a data frame
assert_data_frame(reports)
# Perform checks depending on the model to the data is meant to be used with
model <- match.arg(
model,
c("estimate_infections",
"estimate_truncation",
"estimate_secondary"
)
model <- arg_match(
model,
values = c(
"estimate_infections",
"estimate_truncation",
"estimate_secondary"
)
)

if (model == "estimate_secondary") {
# Check that reports has the right column names
Expand Down

0 comments on commit d5c3ebb

Please sign in to comment.