Inspected revision: 35f3e6b6acdc9df838d03a0584b2b7bdca24b08a.
prune_random_results documents a limit of at most samples_per_bin per quantile bin, but asks NumPy to draw exactly that many without replacement. Sparse or empty bins therefore raise ValueError instead of retaining their available examples.
import numpy as np
from chirp.inference import call_density
from chirp.inference.search import search
results = search.TopKSearchResults(1, [search.SearchResult(
embedding=np.array([], dtype=np.float32), score=0.25, sort_score=0.,
filename='clip.wav', timestamp_offset=0.)])
call_density.prune_random_results(
results, np.array([0., 1., 2.]), np.array([0., 0.5, 1.]), 2)
Expected: one retained result. Actual: a sampling-without-replacement error.
The proposed correction caps each draw at the number of available results in that bin. Bin assignment, selection without replacement and the final shuffle remain unchanged. Nineteen regression/control cases using real result classes reproduce seven failures on original code and pass with the correction. Well-populated bins retain exactly the same seeded choices and generator state. Existing call-density and search tests also pass.
No matching report or competing implementation was found. A focused PR is being prepared.
Inspected revision:
35f3e6b6acdc9df838d03a0584b2b7bdca24b08a.prune_random_resultsdocuments a limit of at mostsamples_per_binper quantile bin, but asks NumPy to draw exactly that many without replacement. Sparse or empty bins therefore raiseValueErrorinstead of retaining their available examples.Expected: one retained result. Actual: a sampling-without-replacement error.
The proposed correction caps each draw at the number of available results in that bin. Bin assignment, selection without replacement and the final shuffle remain unchanged. Nineteen regression/control cases using real result classes reproduce seven failures on original code and pass with the correction. Well-populated bins retain exactly the same seeded choices and generator state. Existing call-density and search tests also pass.
No matching report or competing implementation was found. A focused PR is being prepared.