Skip to content

Commit

Permalink
allow stepsize in forge and expct if not running in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
mnwright committed May 28, 2024
1 parent 4d9c6b0 commit 4435085
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
26 changes: 13 additions & 13 deletions R/expct.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,27 @@ expct <- function(
step_no <- 1
} else {
evidence <- as.data.table(evidence)
if (ncol(evidence) == 2 && all(colnames(evidence) == c("f_idx", "wt"))) {
stepsize <- nrow(evidence)
step_no <- 1
} else if (parallel & evidence_row_mode == "separate") {
# For "separate", parallelize in forge (not in cforde)
if (stepsize == 0) {
if (stepsize == 0) {
if (parallel) {
stepsize <- ceiling(nrow(evidence)/foreach::getDoParWorkers())
} else {
stepsize <- nrow(evidence)
}
}
if (ncol(evidence) == 2 && all(colnames(evidence) == c("f_idx", "wt"))) {
stepsize <- nrow(evidence)
} else if (evidence_row_mode == "separate") {
# For "separate", parallelize in expct (not in cforde)
stepsize_cforde <- 0
parallel_cforde = FALSE
step_no <- ceiling(nrow(evidence)/stepsize)
} else {
# For "or", parallelize in cforde (not in forge)
if (stepsize == 0) {
stepsize <- nrow(evidence)
}
stepsize_cforde <- stepsize
# For "or", parallelize in cforde (not in expct)
parallel_cforde <- parallel
stepsize_cforde <- stepsize
parallel <- FALSE
stepsize <- nrow(evidence)
step_no <- 1
}
step_no <- ceiling(nrow(evidence)/stepsize)
}

# Check query
Expand Down
22 changes: 11 additions & 11 deletions R/forge.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,27 @@ forge <- function(
step_no <- 1
} else {
evidence <- as.data.table(evidence)
if (stepsize == 0) {
if (parallel) {
stepsize <- ceiling(nrow(evidence)/foreach::getDoParWorkers())
} else {
stepsize <- nrow(evidence)
}
}
if (ncol(evidence) == 2 && all(colnames(evidence) == c("f_idx", "wt"))) {
stepsize <- nrow(evidence)
step_no <- 1
} else if (parallel & evidence_row_mode == "separate") {
} else if (evidence_row_mode == "separate") {
# For "separate", parallelize in forge (not in cforde)
if (stepsize == 0) {
stepsize <- ceiling(nrow(evidence)/foreach::getDoParWorkers())
}
stepsize_cforde <- 0
parallel_cforde = FALSE
step_no <- ceiling(nrow(evidence)/stepsize)
} else {
# For "or", parallelize in cforde (not in forge)
if (stepsize == 0) {
stepsize <- nrow(evidence)
}
stepsize_cforde <- stepsize
parallel_cforde <- parallel
stepsize_cforde <- stepsize
parallel <- FALSE
stepsize <- nrow(evidence)
step_no <- 1
}
step_no <- ceiling(nrow(evidence)/stepsize)
}

# Run in parallel for each step
Expand Down

0 comments on commit 4435085

Please sign in to comment.