Skip to content

Commit

Permalink
Update rejection order output to be programmatic
Browse files Browse the repository at this point in the history
  • Loading branch information
EeethB committed Sep 8, 2023
1 parent 1bde0df commit 710a9fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
23 changes: 8 additions & 15 deletions R/graph_rejection_orderings.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ graph_rejection_orderings <- function(shortcut_test_result) {
list_possible_orderings <- apply(
expand.grid(rep(list(rejected), length(rejected))),
1,
function(row) if (length(unique(row)) == length(row)) unname(row) else NULL
function(row) {
if (length(unique(row)) == length(row)){
setNames(row, hyp_names[row])
} else {
NULL
}
}
)
list_possible_orderings <- Filter(Negate(is.null), list_possible_orderings)

Expand All @@ -67,23 +73,10 @@ graph_rejection_orderings <- function(shortcut_test_result) {
}
}

list_orderings_code <- lapply(
list_possible_orderings[orderings_valid],
function(ordering) {
paste0("c(", paste(ordering, collapse = ", "), ")")
}
)

valid_orderings <- do.call(rbind, list_orderings_code)
dimnames(valid_orderings) <- list(
seq_len(length(list_orderings_code)),
"Valid rejection orderings"
)

structure(
c(
shortcut_test_result,
list(valid_orderings = valid_orderings)
list(valid_orderings = list_possible_orderings[orderings_valid])
),
class = "graph_report"
)
Expand Down
10 changes: 6 additions & 4 deletions R/print.graph_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,13 @@ print.graph_report <- function(x, ..., precision = 4, indent = 2, rows = 10) {
if (!is.null(x$valid_orderings)) {
section_break("Alternate rejection orderings ($valid_rejection_orderings)")

apply(
x$valid_orderings, 1,
function(ordering) cat(pad, ordering, "\n", sep = "")
lapply(
x$valid_orderings,
function(ordering) {
print(ordering)
cat("\n")
}
)
cat("\n")
}

invisible(x)
Expand Down

0 comments on commit 710a9fa

Please sign in to comment.