Handle full-store nearest-neighbour queries and single-class votes

#1

For a two-row exemplar store, neighbours(query, 2) raises ValueError because argpartition receives kth=2 rather than kth=1. A one-class store also crashes in vote when it tries to read a nonexistent second class.

Use k - 1 for partitioning and define the single-class margin against zero runner-up share. Validate finite nonempty vectors, class labels, query shape, neighbour bounds, and positive finite vote temperature.

Run python -B -m unittest test_exemplar_contract -v with NumPy installed. All 3 test methods pass after this patch; the base revision fails all 3 methods (including both original crash reproducers). They exercise a complete two-neighbour result in similarity order, a one-example/one-class vote, and invalid input cases. No exemplar assets, downloaded models, or benchmark data are required. This is a boundary-condition repair, not a new recognition benchmark measurement.

Base revision: 271c1832780c25980253fd4816f8e812b064325c.

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment