leader#
- nvmolkit.pickers.leader(
- distance_matrix: AsyncGpuResult | Tensor | ndarray,
- cutoff: float,
- *,
- pick_size: int = 0,
- first_picks: Sequence[int] = (),
- stream: Stream | None = None,
- output: OutputMode = OutputMode.DEVICE,
Select leaders from a distance matrix by sphere exclusion.
Candidates are visited in input order. Each candidate that has not been excluded becomes a leader and excludes every remaining candidate within
cutoffof it, as in RDKit’sLeaderPicker.Distances are compared with
cutoffin float32, so a distance within float32 rounding of the cutoff can be classified differently than by RDKit’sLeaderPicker, which compares in double precision. For Tanimoto distances this can happen at cutoffs that float32 cannot represent exactly, such as 0.3.- Parameters:
distance_matrix – Square float32 or float64 matrix of shape
(N, N). Element[i, j]is the distance from itemito itemj. Values are converted to float32 for comparisons. Values that overflow float32 during conversion become infinity.cutoff – Inclusive exclusion distance, rounded to float32. Must be between zero and the largest finite float32 value.
pick_size – Maximum number of leaders, or
0for no limit. Allfirst_picksare retained even if they exceed this limit.first_picks – Unique indices selected as leaders, in order, before the input-order pass.
stream – CUDA stream to use. If None, uses the current stream.
output – Result representation.
- Returns:
An
AsyncGpuResultof int32 indices forOutputMode.DEVICE, or a tuple of indices forOutputMode.RDKIT.