Conversation
…d tests Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ValueError in extended_metrics when IoU=0.50 is missing
Fix: Feb 19, 2026
extended_metrics raises clear ValueError when IoU=0.50 absent from iouThrs
Borda
approved these changes
Feb 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where COCOeval_faster.extended_metrics crashes with a cryptic error when IoU threshold 0.50 is not present in params.iouThrs. The fix replaces an unconditional .item() call with a guarded lookup that raises a descriptive ValueError when the required threshold is missing.
Changes:
- Fixed crash in
extended_metricswhen IoU=0.50 is absent fromiouThrsby adding explicit validation - Added comprehensive test coverage for both the error case and normal operation
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| faster_coco_eval/core/faster_eval_api.py | Replaced unconditional .item() with guarded np.where() lookup and added descriptive error message |
| tests/test_simple_extra.py | Added helper function and two tests to verify error handling and normal operation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
Thanks for the implementation, everything is great! |
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.
COCOeval_faster.extended_metricscrashed with a crypticValueError: can only convert an array of size 1 to a Python scalarwheneverparams.iouThrsdidn't include0.50, becausenp.argwhere(...).item()blows up on an empty array.Motivation
Any caller customising
params.iouThrsto a set that excludes0.50(e.g. single-threshold or high-IoU-only evaluation) hits an opaque crash with no indication of what went wrong.Modification
faster_coco_eval/core/faster_eval_api.py: Replace the unconditional.item()call with a guardednp.where(...)lookup. Raises a descriptiveValueErrornaming the missing threshold when0.50is absent.tests/test_simple_extra.py: Add_make_coco_eval()helper and two tests — one asserting the newValueErrorfires when0.50is absent, one asserting normal operation when using defaultiouThrs.BC-breaking (Optional)
Previously the crash produced a generic
ValueError; it now produces a more descriptive one. Code catching the bareValueErrortype is unaffected. Code matching on the old message (unlikely) would need updating.Checklist
Original prompt
extended_metricscrashes withValueErrorwhen IoU=0.50 is not iniouThrs#72✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.