Skip to content

Commit

Permalink
minor fix gammaCKpar
Browse files Browse the repository at this point in the history
  • Loading branch information
tedenamorado committed Sep 5, 2018
1 parent 7493f37 commit 1b108fb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
15 changes: 10 additions & 5 deletions R/gammaCK2par.R
Expand Up @@ -162,18 +162,23 @@ gammaCK2par <- function(matAp, matBp, n.cores = NULL, cut.a = 0.92, method = "jw
registerDoParallel(cl)
on.exit(stopCluster(cl))
}

final.list2 <- foreach(i = 1:length(matches.2)) %oper% {
if(length(matches.2) > 0) {
final.list2 <- foreach(i = 1:length(matches.2)) %oper% {
ht1 <- which(matrix.1 == matches.2[[i]][[1]]); ht2 <- which(matrix.2 == matches.2[[i]][[2]])
list(ht1, ht2)
}

}
}
} else {
no_cores <- n.cores
final.list2 <- mclapply(matches.2, function(s){
final.list2 <- mclapply(matches.2, function(s){
ht1 <- which(matrix.1 == s[1]); ht2 <- which(matrix.2 == s[2]);
list(ht1, ht2) }, mc.cores = getOption("mc.cores", no_cores))
}

if(length(matches.2) == 0){
final.list2 <- list()
warning("There are no identical (or nearly identical) matches. We suggest either changing the value of cut.p")
}

na.list <- list()
na.list[[1]] <- which(matrix.1 == "9999")
Expand Down
18 changes: 11 additions & 7 deletions R/gammaCKpar.R
Expand Up @@ -173,24 +173,23 @@ gammaCKpar <- function(matAp, matBp, n.cores = NULL, cut.a = 0.92, cut.p = 0.88,
cl <- makeCluster(n.cores)
registerDoParallel(cl)
}

final.list2 <- foreach(i = 1:length(matches.2)) %oper% {
if(length(matches.2) > 0) {
final.list2 <- foreach(i = 1:length(matches.2)) %oper% {
ht1 <- which(matrix.1 == matches.2[[i]][[1]]); ht2 <- which(matrix.2 == matches.2[[i]][[2]])
list(ht1, ht2)
}

}
}
if(length(matches.1) > 0) {
final.list1 <- foreach(i = 1:length(matches.1)) %oper% {
final.list1 <- foreach(i = 1:length(matches.1)) %oper% {
ht1 <- which(matrix.1 == matches.1[[i]][[1]]); ht2 <- which(matrix.2 == matches.1[[i]][[2]])
list(ht1, ht2)
}
}

if(n.cores > 1){
stopCluster(cl)
}
} else {
no_cores <- n.cores
no_cores <- n.cores
final.list2 <- mclapply(matches.2, function(s){
ht1 <- which(matrix.1 == s[1]); ht2 <- which(matrix.2 == s[2]);
list(ht1, ht2) }, mc.cores = getOption("mc.cores", no_cores))
Expand All @@ -199,6 +198,11 @@ gammaCKpar <- function(matAp, matBp, n.cores = NULL, cut.a = 0.92, cut.p = 0.88,
ht1 <- which(matrix.1 == s[1]); ht2 <- which(matrix.2 == s[2]);
list(ht1, ht2) }, mc.cores = getOption("mc.cores", no_cores))
}

if(length(matches.2) == 0){
final.list2 <- list()
warning("There are no identical (or nearly identical) matches. We suggest either changing the value of cut.p")
}

if(length(matches.1) == 0){
final.list1 <- list()
Expand Down

0 comments on commit 1b108fb

Please sign in to comment.