kups.core.neighborlist.compact
¶
Compactors for the neighbor list pipeline.
Two flavors:
ReduceCompactor— compresses survivors viajnp.where(keep, size=k)with a capacity assertion; mirrors edges whenctx.rh_index_remapis set.MaskOnlyCompactor— preserves the candidate count, replacing failing entries with OOB indices and zero shifts. Used byRefineMaskNeighborList.
Both compactors share the rh→lh remap (remap_rh_to_lh) so that the
final Edges indices live in lh-space regardless of which compactor ran.
Mirroring (doubling each edge with its reverse) is specific to
ReduceCompactor — it pairs with RemapDedupMask which removed one
direction of each pair upstream.
MaskOnlyCompactor
¶
In-place compaction: failing entries become OOB indices and zero shifts.
No size change; preserves the candidate count from the selector. Applies
the shared rh→lh remap so the output indices live in lh-space — matching
ReduceCompactor's contract.
Source code in src/kups/core/neighborlist/compact.py
ReduceCompactor
¶
Compacts surviving candidates to a size-bounded Edges[2].
Applies the shared rh→lh remap, then — when ctx.rh_index_remap is
set — mirrors each surviving edge with its reverse (concatenating shifts
with their negatives). The mirror restores the symmetry that the paired
RemapDedupMask removed upstream.
Source code in src/kups/core/neighborlist/compact.py
remap_rh_to_lh(rh_idx, ctx)
¶
Map rh-space indices to lh-space via ctx.rh_index_remap.
Returns rh_idx unchanged when no remap is in effect. Out-of-bounds
rh positions (e.g., padding) resolve to max(ctx.lh.size, ctx.rh.size).