Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recall sweep computation. #5472

Merged
merged 2 commits into from
Feb 6, 2025
Merged

Conversation

wickeat
Copy link
Contributor

@wickeat wickeat commented Feb 5, 2025

What changes are proposed in this pull request?

Check for recall array emptiness before assigning to recall_sweep variable.

How is this patch tested? If it is not, please explain why.

Tested _compute_pr_curves() locally with generated input args.

Release Notes

Is this a user-facing change that should be mentioned in the release notes?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release
    notes for FiftyOne users.

Fix exception on _compute_pr_curves when recall value does not exist.

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced the reliability of evaluation processing by adding a safeguard that prevents errors when encountering empty data arrays. This improvement ensures that evaluations run smoothly even in scenarios with missing recall values.

Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Walkthrough

The pull request updates the _compute_pr_curves function in fiftyone/utils/eval/coco.py by adding a conditional check before assigning a value from the rec array to recall_sweep. This ensures that the assignment is only performed when the rec array is non-empty, preventing an IndexError in cases where predictions contain no positives. No other aspects of the code or public API were modified.

Changes

File Change Summary
fiftyone/.../utils/eval/coco.py Modified _compute_pr_curves function to add a conditional check that verifies the rec array is non-empty before assigning its last element to recall_sweep.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Evaluation Routine
    participant Curve as _compute_pr_curves
    participant Rec   as rec array
    participant Sweep as recall_sweep

    Caller->>Curve: Invoke evaluation process
    Curve->>Rec: Compute recall values
    alt Rec is non-empty
        Curve->>Sweep: Assign last element of rec (rec[-1])
    else Rec is empty
        Curve->>Sweep: Skip assignment to avoid error
    end
Loading

Poem

In the meadow of code, I hop with delight,
Inspecting each array in the crisp digital light.
A simple check ensures no out-of-bound plight,
Errors vanish like shadows in the night.
With a twitch of my whiskers, bugs take flight—
Hoppy coding days keep the code just right! 🐰🌟

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 37067d5 and 0fd94fd.

📒 Files selected for processing (1)
  • fiftyone/utils/eval/coco.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • fiftyone/utils/eval/coco.py

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 124d447 and 37067d5.

📒 Files selected for processing (1)
  • fiftyone/utils/eval/coco.py (1 hunks)

fiftyone/utils/eval/coco.py Show resolved Hide resolved
@brimoor
Copy link
Contributor

brimoor commented Feb 5, 2025

@manushreegangwar can you please confirm this is how we should handle empty recall?

Copy link

codecov bot commented Feb 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.19%. Comparing base (77410fe) to head (0fd94fd).
Report is 181 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5472      +/-   ##
===========================================
- Coverage    99.20%   99.19%   -0.01%     
===========================================
  Files           54       54              
  Lines        18635    18655      +20     
===========================================
+ Hits         18486    18505      +19     
- Misses         149      150       +1     
Flag Coverage Δ
python 99.19% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@manushreegangwar manushreegangwar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching and fixing this!

@manushreegangwar manushreegangwar self-requested a review February 5, 2025 16:56
fiftyone/utils/eval/coco.py Show resolved Hide resolved
fiftyone/utils/eval/coco.py Show resolved Hide resolved
@manushreegangwar
Copy link
Contributor

@manushreegangwar can you please confirm this is how we should handle empty recall?

@brimoor Please see #5472 (comment)

Co-authored-by: manushreegangwar <[email protected]>
@brimoor brimoor merged commit 5a1a2d5 into voxel51:develop Feb 6, 2025
10 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants