Skip to content

node_type_index's docstring says it counts records; it counts occurrences #374

Description

@realmarcin

Found reviewing #366.

node_type_index() is documented as:

node_id{node_type: number of records using it}, corpus-wide.

It counts node occurrences, not records — index[nid][ntype] += 1 runs per node, inside the per-graph loop.

Today those are the same number, and I checked rather than assumed: no node_id appears twice in one graph, and none appears in two graphs of the same record (0 and 0 across the corpus). So the docstring is accidentally true.

It is true by coincidence, not by construction. The moment one record carries the same node_id in two of its graphs — which nothing forbids — the counts diverge and the finding text inherits it:

node_id='proton_motive_force' type=CAPACITY here — also STATE×18 … elsewhere in the corpus

STATE×18 would then overstate how many records disagree, in a message whose whole job is to size the disagreement.

test_node_type_index_counts_records_per_type doesn't pin the distinction either — its fixtures have one graph per record, so it passes under either reading.

Fix: say "occurrences" and count occurrences (the simpler option, and what the detail line actually wants), or count records and add a fixture with one node_id in two graphs of one record to hold it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions