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,
) → AsyncGpuResult | tuple[int, ...]#

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 cutoff of it, as in RDKit’s LeaderPicker.

Distances are compared with cutoff in float32, so a distance within float32 rounding of the cutoff can be classified differently than by RDKit’s LeaderPicker, 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 item i to item j. 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 0 for no limit. All first_picks are 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 AsyncGpuResult of int32 indices for OutputMode.DEVICE, or a tuple of indices for OutputMode.RDKIT.