Skip to content

Commit

Permalink
Move input checking on nsim_obs where it is first needed
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmbaazam committed Mar 22, 2024
1 parent 6f3e3cd commit 80115cd
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions R/likelihood.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ likelihood <- function(chains, statistic = c("size", "length"), offspring_dist,
statistic <- match.arg(statistic)

## Input checking
## Check nsim_obs when specified
if (!missing(nsim_obs)) {
checkmate::assert_number(
nsim_obs, lower = 1, finite = TRUE, na.ok = FALSE
)
}
checkmate::assert(
checkmate::check_numeric(
chains, lower = 0, upper = Inf, any.missing = FALSE
Expand Down Expand Up @@ -145,6 +139,10 @@ likelihood <- function(chains, statistic = c("size", "length"), offspring_dist,
if (obs_prob < 1) {
if (missing(nsim_obs)) {
stop("'nsim_obs' must be specified if 'obs_prob' is < 1")
} else {
checkmate::assert_number(
nsim_obs, lower = 1, finite = TRUE, na.ok = FALSE
)
}

statistic_func <- .get_statistic_func(statistic)
Expand Down

0 comments on commit 80115cd

Please sign in to comment.