fix: validate batch_size and empty-query benchmarks - #25
Closed
HarshRajSinghania wants to merge 1 commit into
Closed
HarshRajSinghania wants to merge 1 commit into
HarshRajSinghania wants to merge 1 commit into
Conversation
Reject batch_size < 1 with ValueError("batch_size must be >= 1") instead of a raw range() error.
Return zeroed ModeResult metrics when a dataset has no queries instead of dividing by zero.
Member
|
Thanks! Merging #26 for this one since it also guards ingest_documents directly (fail-fast) with lighter mock-based tests. Appreciate the work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Guard two unhandled boundary cases in ingestion and the benchmark harness.
Motivation
ingest_documents(..., batch_size=0)(viabatched) raisedValueError: range() arg 3 must not be zero.run_benchmarkon a dataset with zero queries raisedZeroDivisionErrorfromsum(r5) / len(r5).Both issues are open, unassigned, labeled help wanted / good first issue, with explicit acceptance criteria. No open PRs existed for them.
Implementation
batched()now raisesValueError("batch_size must be >= 1")whensize < 1.run_benchmarktreats empty per-mode recall lists as 0.0 instead of dividing by zero. Mode results are still emitted withn_queries=0andqps=0.0. Index recall for non-dense / empty cases remains NaN as before.Testing
Ran locally:
Result: 34 passed.
New coverage:
tests/test_ingest.py:batched([1,2,3], 0)andbatch_size=-1raise the specified error;ingest_documents(..., batch_size=0)does the same.tests/test_benchmark.py::test_benchmark_zero_queries_returns_empty_modes: empty query set returns modes with zeroed metrics.Fixes #22
Fixes #23