xmap_diagnosis is the shared return contract for diagnose_as_xmap_*()
functions across crossmap representations (data frame, matrix, graph,
...): a single object shape regardless of whether the diagnosis passed
or failed, so callers can inspect $valid programmatically, or print
the object for a human-readable report of what needs fixing.
Usage
new_xmap_diagnosis(
valid,
details,
labels,
class = character(),
msg_valid,
msg_invalid
)Arguments
- valid
A single logical: did every check pass?
- details
A named list of tibbles (or
NULL), one entry per check.NULLmeans that check passed; a tibble holds the offending locations.- labels
A named list, one entry per check (same names as
details), each entry a length-2 character vector with elementspassandfail— the text to show when that check passed or failed, respectively. A single check reads differently depending on outcome (e.g. "No duplicate pairs" vs. "Duplicate pairs found").- class
Additional subclass(es) to prepend, e.g.
"xmap_diagnosis_tbl", for representation-specific methods beyond printing.- msg_valid, msg_invalid
The headline
climessage shown byprint.xmap_diagnosis()whenvalidisTRUE/FALSErespectively.
Details
The set of checks, their labels, and what counts as an "offending
location" (rows, matrix cells, graph edges, ...) is specific to each
representation. Callers of new_xmap_diagnosis() supply labels for
their own checks, and are responsible for normalizing each check's
offending locations into a tibble before passing them in details —
print.xmap_diagnosis() stays representation-agnostic by only ever
printing tibbles.
