|
6 | 6 | #' @param x [validate::validator()] object with rule |
7 | 7 | #' @param rule_name `character` with the names of the rules to be checked |
8 | 8 | #' @param ... not used |
| 9 | +#' @param verbose if `TRUE` print information to the console |
9 | 10 | #' @family redundancy |
10 | 11 | #' @return `character` with the names of the rule that cause the implication. |
11 | | -is_implied_by <- function(x, rule_name, ...){ |
| 12 | +is_implied_by <- function(x, rule_name, ..., verbose = interactive()){ |
12 | 13 | check_validator(x) |
13 | 14 | idx <- match(rule_name, names(x), 0) |
14 | 15 | if (any(idx == 0L)){ |
@@ -41,7 +42,18 @@ is_implied_by <- function(x, rule_name, ...){ |
41 | 42 | # names(weight) <- names(negated_rules) |
42 | 43 | # detect_infeasible_rules(test_rules, weight) |
43 | 44 |
|
44 | | - is_contradicted_by(test_rules, names(negated_rules), verbose = FALSE) |
| 45 | + res <- is_contradicted_by(test_rules, names(negated_rules), verbose = FALSE) |
| 46 | + if (isTRUE(verbose) && length(res)){ |
| 47 | + v <- x[rule_name] |> to_exprs() |> lapply(deparse_all) |
| 48 | + v_i <- x[res] |> to_exprs() |> lapply(deparse_all) |
| 49 | + message( |
| 50 | + "Rule(s)\n", |
| 51 | + paste0(" ", names(v),": ", v, collapse = "\n"), |
| 52 | + "\nimplied by:\n", |
| 53 | + paste0(" ", names(v_i),": ", v_i, collapse = "\n") |
| 54 | + ) |
| 55 | + } |
| 56 | + res |
45 | 57 | } |
46 | 58 |
|
47 | 59 | # rules <- x <- validator(r1 = x > 1, r2 = x > 2) |
|
0 commit comments