Skip to content

Commit

Permalink
Remove commented code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Naeemkh committed Mar 16, 2022
1 parent c264263 commit 754b04f
Showing 1 changed file with 3 additions and 55 deletions.
58 changes: 3 additions & 55 deletions R/create_matching.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,42 +60,7 @@ create_matching <- function(dataset, bin_seq = NULL, gps_model = "parametric",
logger::log_debug("Started generating matched set ...")
st_t_m <- proc.time()

lfp <- get_options("logger_file_path")

# p5_c_t_s <- proc.time()
# cl <- parallel::makeCluster(nthread, type="PSOCK",
# outfile= lfp)

# seed_val <- .Random.seed
# parallel::clusterSetRNGStream(cl = cl, iseed = seed_val)

# parallel::clusterEvalQ(cl, {library("CausalGPS")})
# p_c_t_e <- proc.time()

# logger::log_debug("Wall clock time to create cluster with ",
# "{nthread} core(s): {p_c_t_e[[3]] - p_c_t_s[[3]]} s.")
# parallel::clusterExport(cl=cl,
# varlist = c("bin_num", "matching_fun", "dataset",
# "gps_mx", "w_mx", "delta_n", "scale",
# "nthread", "compute_closest_wgps",
# "compute_resid", "compute_density"),
# envir=environment())

# matched_set <- parallel::parLapply(cl,
# bin_num,
# matching_fun,
# dataset=dataset[[1]],
# e_gps_pred = dataset[[2]],
# e_gps_std_pred = dataset[[3]],
# w_resid=dataset[[4]],
# gps_mx = gps_mx,
# w_mx = w_mx,
# gps_model = gps_model,
# delta_n = delta_n,
# scale = scale,
# nthread = nthread,
# optimized_compile = optimized_compile)
# parallel::stopCluster(cl)
#lfp <- get_options("logger_file_path")

matched_set <- lapply(bin_num,
matching_fun,
Expand All @@ -110,7 +75,6 @@ create_matching <- function(dataset, bin_seq = NULL, gps_model = "parametric",
scale = scale,
nthread = nthread,
optimized_compile = optimized_compile)
#parallel::stopCluster(cl)

e_t_m <- proc.time()
logger::log_debug("Finished generating matched set (Wall clock time: ",
Expand All @@ -124,29 +88,13 @@ create_matching <- function(dataset, bin_seq = NULL, gps_model = "parametric",

s_comp_p <- proc.time()

# # old solution
# s_old <- proc.time()
#
# cp_original_data <- dataset[[1]]
# bind_matched_set = do.call(rbind,matched_set)
# freq_table = as.data.frame(table(bind_matched_set))
# index_of_data <- as.numeric(as.character(freq_table[1][,1]))
# added_count <- as.numeric(as.character(freq_table[2][,1]))
# #index_of_data <- freq_table[1][,1]
# #added_count <- freq_table[2][,1]
#
# e_old <- proc.time()
#
# print(paste0("Finished old version (Wall clock time: ",
# (e_old - s_old)[[3]]," seconds)."))

# New solution
cp_original_data <- dataset[[1]]
logger::log_debug("Started working on binding the matched set ... ")
s_bindlist <- proc.time()
bind_matched_set <- data.table::rbindlist(matched_set)
e_bindlist <- proc.time()
logger::log_debug(paste0("Finished binding the matched set - rbindlist(Wall clock time: ",
logger::log_debug(paste0("Finished binding the matched set -",
"rbindlist(Wall clock time: ",
(e_bindlist - s_bindlist)[[3]]," seconds)."))

bind_matched_set$row_index <- as.integer(bind_matched_set$row_index)
Expand Down

0 comments on commit 754b04f

Please sign in to comment.