Skip to content

comicbox.readinglists.combine.groups ¶

Which rows of several lists are the same issue.

Every row is a node (input index, row index) carrying its entry_keys. A key is qualified by how many earlier rows of its own input carry it, so the first occurrence of a repeated issue lines up with the first in another list and the second with the second. The cover-year key is counted among rows of the same signature (discriminators): rows of two volumes are not repeats of one issue.

Two rows of different inputs that share a qualified key are linked, and links join groups transitively: a ComicVine id joining A and B and a Metron id joining B and C put all three together. Links are applied strongest first, ids in ranked_id_sources order, then names with a start year, then names with a volume number, then names with a cover year, and within one strength by input rank and row. A volume-number link is refused when the joined group would hold two years: Z-Men (1963) and Z-Men (1991) may both be volume 1. A link that would put two rows of one input in one group is refused, so a name match never takes a row an id match wanted, nor a cover-year match one a name match wanted, and nothing is cut apart afterwards.

The cover-year key links a row to its candidates: rows of other inputs with the same key and occurrence whose signatures do not conflict with its own. An exact candidate has the same signature, a loose one another. Every exact pair is linked, so a list combines with itself unchanged. A loose pair is linked only when neither row has an exact candidate in the other’s input, each is the other’s only loose candidate there, and neither has two candidates that conflict over all the other inputs: a row that cannot tell which volume it is stays its own entry. No group formed through cover-year links holds two rows whose signatures conflict.

GroupIdConflict dataclass ¶

Two values for one source in one group; group is a group id.

Source code in comicbox/readinglists/combine/groups.py
87
88
89
90
91
92
93
94
95
96
@dataclass(frozen=True, slots=True)
class GroupIdConflict:
    """Two values for one source in one group; ``group`` is a group id."""

    group: int
    source: str
    kept: str
    dropped: str
    input_index: int
    row: int

Grouping dataclass ¶

The groups of rows that are the same issue.

Group ids number the groups by first appearance, reading the inputs in rank order. members holds each group’s nodes in rank order, at most one per input. sequences holds each input’s group ids in row order.

Source code in comicbox/readinglists/combine/groups.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
@dataclass(frozen=True, slots=True)
class Grouping:
    """
    The groups of rows that are the same issue.

    Group ids number the groups by first appearance, reading the inputs in
    rank order. ``members`` holds each group's nodes in rank order, at most
    one per input. ``sequences`` holds each input's group ids in row order.
    """

    members: tuple[tuple[Node, ...], ...]
    sequences: tuple[tuple[int, ...], ...]
    id_conflicts: tuple[GroupIdConflict, ...]
    name_joins: frozenset[int]

group_rows(inputs) ¶

Group the rows of lists, in rank order, that are the same issue.

Source code in comicbox/readinglists/combine/groups.py
345
346
347
def group_rows(inputs: Sequence[Sequence[Mapping[str, Any]]]) -> Grouping:
    """Group the rows of lists, in rank order, that are the same issue."""
    return _Grouper(inputs).group()