Skip to content

Commit

Permalink
abc smc: minor refactoring to change loop from 'repeat' to 'while'
Browse files Browse the repository at this point in the history
  • Loading branch information
stewid committed Jan 6, 2020
1 parent b266330 commit dcdb581
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions R/abc_smc.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ abc_smc <- function(model, priors, ngen, npart, fn, ..., verbose = TRUE) {
ancestor <- NULL
tot_proposals <- 0

repeat {
while (ifelse(is.null(xx), 0, ncol(xx)) < npart) {
if (all(n < 1e6, tot_proposals > 2 * n)) {
## Increase the number of particles that is simulated
## in each trajectory.
Expand Down Expand Up @@ -219,9 +219,6 @@ abc_smc <- function(model, priors, ngen, npart, fn, ..., verbose = TRUE) {
ancestor <- c(ancestor, attr(proposals, "ancestor")[result])
}
}

if (ifelse(is.null(xx), 0, ncol(xx)) >= npart)
break
}

## Calculate weights.
Expand Down

1 comment on commit dcdb581

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R/abc_smc.R:151:1: style: functions should have cyclomatic complexity of less than 15, this has 17.

abc_smc <- function(model, priors, ngen, npart, fn, ..., verbose = TRUE) {
^

Please sign in to comment.