Skip to content

Commit

Permalink
fix all NA condition rows bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jkapar committed Mar 1, 2024
1 parent 9af0a8f commit 0da0b5a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/forde.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ forde <- function(
max_j <- max(x[[j]], na.rm = TRUE)
gap <- max_j - min_j
lb[, j] <- min_j - epsilon / 2 * gap
ub[, j] <- max_j #+ epsilon / 2 * gap
ub[, j] <- max_j + epsilon / 2 * gap
}
}
for (i in 1:num_nodes) {
Expand Down
5 changes: 4 additions & 1 deletion R/forge.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
#' @importFrom foreach foreach %dopar%
#' @importFrom truncnorm rtruncnorm
#' @importFrom stats rbinom
#'
#'

forge <- function(
params,
Expand Down Expand Up @@ -120,6 +120,9 @@ forge <- function(
index_end <- min(step_*stepsize_foreach, nrow(condition))
condition_part <- condition[index_start:index_end,]
cparams <- cforde(params, condition_part, condition_row_mode, stepsize)
if(is.null(cparams)) {
n_synth <- n_synth * nrow(condition_part)
}
} else {
cparams <- NULL
}
Expand Down
1 change: 1 addition & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ cforde <- function(params, condition, row_mode = c("separate", "or"), stepsize =
}
if(row_mode == "separate" & (nconds != nconds_conditioned)) {
conds_unconditioned <- (1:nconds)[!(1:nconds) %in% conds_conditioned]
forest_new <- forest_new[!(c_idx %in% conds_unconditioned),]
forest_new_unconditioned <- copy(forest)
forest_new_unconditioned <- rbindlist(replicate(length(conds_unconditioned), forest, simplify = F))
forest_new_unconditioned[, `:=` (c_idx = rep(conds_unconditioned,each = nrow(forest)), f_idx_uncond = f_idx, cvg_arf = cvg)]
Expand Down

0 comments on commit 0da0b5a

Please sign in to comment.