69 """The ``pair_k`` best pairs as (first, second, score), best first.
71 The score of a pair is the sum of the not-near counts of its two dimensions.
72 Pairs are ordered by descending score, then by ascending (first, second)
73 name, both byte-wise. Fewer pairs are returned when fewer exist.
75 names = sorted(counts, key=name_key)
77 (counts[first] + counts[second], first, second)
78 for position, first
in enumerate(names)
79 for second
in names[position + 1 :]
81 pairs.sort(key=
lambda pair: (-pair[0], name_key(pair[1]), name_key(pair[2])))
82 return [(first, second, score)
for score, first, second
in pairs[:pair_k]]
90def plan_pairs(study: Study, values: dict, profile: dict, pair_k: int) -> list:
91 """Rank the pairs of one centre and span their maps; looks nothing up.
93 ``values`` is the centre's normalised vector and ``profile`` its
94 per-dimension neighbour cells as ``neighbourhood`` builds them.
101 _axis(study, values, profile, first),
102 _axis(study, values, profile, second),