fix(retrieval): validate top_k parameter for RetrievalMAP and RetrievalMRR#3418
Open
jlaportebot wants to merge 13 commits into
Open
fix(retrieval): validate top_k parameter for RetrievalMAP and RetrievalMRR#3418jlaportebot wants to merge 13 commits into
jlaportebot wants to merge 13 commits into
Conversation
…alMRR - Fix validation logic in RetrievalMAP and RetrievalMRR class constructors - Fix validation logic in retrieval_average_precision and retrieval_reciprocal_rank functional APIs - Change condition from 'not isinstance(top_k, int) and top_k <= 0' to 'not (isinstance(top_k, int) and top_k > 0)' to correctly reject non-positive integers and non-integer values - Add regression tests for invalid top_k values (-10, 4.0) in class and functional APIs Fixes Lightning-AI#3378
7b55b79 to
4fab1c2
Compare
…ll retrieval metrics
- Update error message format from '`top_k` has to be a positive integer or None' to
'Argument ``top_k`` has to be a positive integer or None, but got {top_k}' for consistency
- Applied to class metrics: FallOut, NDCG, AUROC, Recall, Precision, HitRate
- Applied to functional metrics: retrieval_fall_out, retrieval_normalized_dcg, retrieval_auroc,
retrieval_recall, retrieval_precision, retrieval_hit_rate
- Fixes test failures in PR Lightning-AI#3418 where test expectations were updated but validation code was not
- Follows the pattern established in RetrievalMAP and RetrievalMRR (commit 4fab1c2)
Fixes Lightning-AI#3378
35d3496 to
be03c64
Compare
for more information, see https://pre-commit.ci
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3418 +/- ##
======================================
- Coverage 37% 36% -0%
======================================
Files 349 349
Lines 19901 19928 +27
======================================
+ Hits 7264 7265 +1
- Misses 12637 12663 +26 🚀 New features to boost your workflow:
|
Add [dependency-groups] section to pyproject.toml for modern uv-based development dependency management. This enables 'uv sync --group dev' for installing development tooling like pytest and pytest-cov. Follows PEP 735 standard for dependency groups.
Regenerate uv.lock after adding [dependency-groups] for dev tooling (PEP 735). The lock file now correctly resolves pytest and pytest-cov for the dev group.
0bca73b to
00ffb26
Compare
for more information, see https://pre-commit.ci
Lightning-AI#2846) - Update _generalized_dice_update to return support tracking for per-class computation - Update _generalized_dice_compute to handle per_class=True with NaN for absent classes - Update GeneralizedDiceScore class to track support and compute per-class scores correctly - Add test for absent classes handling (TestGeneralizedDiceScoreAbsentClasses) Classes not present in any sample now return NaN. Classes present in only some samples average over present samples only.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
- Fix _generalized_dice_compute support parameter type annotation (Tensor | None) - Add class attribute type annotations for score, support, samples state variables
…ed_dice_score doctests Doctests using torch.randint produce non-deterministic output, causing CI failures across platforms (observed on Windows/macOS/Linux with different PyTorch versions). Replace with fixed literal tensors that produce deterministic results. Fixes CI failures in pytester jobs across all platforms.
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
Testing
Fixes #3378