Skip to content

Commit 6b49954

Browse files
Add some internal documentation
1 parent 696edce commit 6b49954

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

R/ccdrAlgorithm-bwlist.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ names_to_indices <- function(v, names){
2121
match(v, names)
2222
} # END NAMES_TO_INDICES
2323

24+
### Returns a list whose components are the rows of a matrix
2425
rows_to_list <- function(m){
2526
lapply(1:nrow(m), function(j) m[j,])
2627
} # END ROWS_TO_LIST
2728

29+
### Check correctness of input and transform from matrix to list of indices
2830
bwlist_check <- function(bwlist, names){
31+
## Consistency checks
2932
if(!is.matrix(bwlist) || ncol(bwlist) != 2){
3033
stop("Input must be a matrix with exactly 2 columns!")
3134
}
@@ -34,16 +37,21 @@ bwlist_check <- function(bwlist, names){
3437
stop("Input cannot have missing values!")
3538
}
3639

40+
### Convert characters names to indices
3741
if(is.character(bwlist)){
3842
bwlist <- as.vector(bwlist)
3943
bwlist <- names_to_indices(bwlist, names)
4044
bwlist <- matrix(bwlist, ncol = 2)
4145
}
4246

43-
storage.mode(bwlist) <- "integer"
47+
storage.mode(bwlist) <- "integer" # This is important in ccdr_call to check overlap between blacklist and whitelist, fails if numerics are mixed with ints
4448
rows_to_list(bwlist)
4549
} # END BWLIST_CHECK
4650

51+
### Convert b/w lists to weight matrix of {-1,0,1}
52+
# -1 = black listed (guaranteed to be absent / zero)
53+
# 0 = white listed (guaranteed to be present / nonzero)
54+
# 1 = gray listed (may or may not be final model)
4755
bwlist_to_weights <- function(black, white, nnode){
4856
weights <- matrix(1L, ncol = nnode, nrow = nnode)
4957

0 commit comments

Comments
 (0)