(3e -> 3a) Add `InstanceGroup` class
Description
This PR adds and implements the InstanceGroup datastructure and should be used to update InstanceGroup.
Types of changes
- [ ] Bugfix
- [x] New feature
- [ ] Refactor / Code style update (no logical changes)
- [ ] Build / CI changes
- [ ] Documentation Update
- [ ] Other (explain)
Does this address any currently open issues?
[list open issues here]
Outside contributors checklist
- [ ] Review the guidelines for contributing to this repository
- [ ] Read and sign the CLA and add yourself to the authors list
- [ ] Make sure you are making a pull request against the develop branch (not main). Also you should start your branch off develop
- [ ] Add tests that prove your fix is effective or that your feature works
- [ ] Add necessary documentation (if appropriate)
Thank you for contributing to SLEAP!
:heart:
Summary by CodeRabbit
-
Refactor
- Updated imports to streamline camera-related functionalities and types.
-
Tests
- Adjusted test imports to align with the refactored camera module.
Walkthrough
The changes encompass a comprehensive overhaul of the camera-related functionalities in SLEAP. This includes refactoring imports, updating logic for handling instances and points, introducing new data structures, and refining the test suite to align with the enhanced codebase.
Changes
| File Path | Change Summary |
|---|---|
sleap/io/cameras.py |
Updated imports, added triangulate import, included new types from sleap.types. |
sleap/gui/commands.pysleap/instance.py |
Enhanced logic for handling instances and points, respectively. |
tests/io/test_cameras.py |
Added new imports, modified function signatures, introduced InstanceGroup and FrameGroup testing functions. |
tests/fixtures/datasets.py |
Added multiview_min_session_user_labels fixture for minimal session user-labeled data. |
tests/gui/test_commands.py |
Removed various test functions related to multi-view triangulation scenarios. |
πβ¨ In the code where cameras lie, A rabbit hopped, refactoring high. With types anew, the tests align, A sleeker codebase, by design. π πΎπΈ
Recent Review Details
Configuration used: CodeRabbit UI
Commits
Files that changed from the base of the PR and between ad5fb9e6a9db4cb84831c1b107a7a3b800e37be9 and 0c057c1284605d3eaf7854125c57b4e7af121ccd.Files selected for processing (6)
- sleap/gui/commands.py (2 hunks)
- sleap/instance.py (2 hunks)
- sleap/io/cameras.py (7 hunks)
- tests/fixtures/datasets.py (1 hunks)
- tests/gui/test_commands.py (1 hunks)
- tests/io/test_cameras.py (2 hunks)
Files not summarized due to errors (1)
- sleap/io/cameras.py: Error: Message exceeds token limit
Additional comments not posted (15)
tests/fixtures/datasets.py (1)
283-288: The new fixturemultiview_min_session_user_labelscorrectly loads user-labeled data for a minimal session. This aligns with the PR's objective to enhance data handling capabilities.tests/io/test_cameras.py (3)
8-14: The updated imports correctly includeInstanceGroupandFrameGroup, which are necessary for the new functionalities being tested.
292-339: The functioncreate_instance_grouphas been updated to optionally include a dummy instance in the returned data. This is useful for testing scenarios where not all data points are valid or present. The implementation handles the conditional logic and data structure manipulation correctly.
342-416: The testtest_instance_groupeffectively checks the functionality of theInstanceGroupdata structure, including edge cases with the dummy instance. The assertions cover various properties and methods, ensuring the structure behaves as expected.sleap/instance.py (8)
Line range hint
34-63: LGTM! ThePointclass implementation is clear and well-defined.
Line range hint
75-110: LGTM! ThePredictedPointclass correctly extends thePointclass with additional functionality for handling prediction scores.
Line range hint
118-183: LGTM! ThePointArrayclass provides necessary functionality for handling arrays ofPointobjects efficiently.
Line range hint
185-209: LGTM! ThePredictedPointArrayclass correctly extendsPointArrayto handlePredictedPointobjects, maintaining consistency in the API.
Line range hint
211-235: LGTM! TheTrackclass implementation is straightforward and provides essential functionality for tracking objects across frames.
500-505: > :memo: NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [237-729]
The methods in the
Instanceclass are well-implemented and cover a wide range of functionalities required for managing instances in SLEAP.
Line range hint
1654-1791: LGTM! ThePredictedInstanceclass correctly extends theInstanceclass to handle additional attributes and functionalities specific to predicted instances.
Line range hint
1793-2428: LGTM! TheLabeledFrameclass provides comprehensive functionality for managing labeled data within a single frame, including methods for merging frames and handling instances.sleap/gui/commands.py (3)
3421-3425: Consider handling the case whereinstance_groupisNonemore explicitly.It might be beneficial to add a specific error message or handling logic when
instance_groupisNone, as this could indicate a deeper issue with the data or assumptions being made.
3444-3449: Ensure that thetriangulatefunction handles exceptions or errors gracefully.
3458-3465: Validate the dimensions and data integrity ofpoints_reprojectedbefore updating.Consider adding checks to ensure that the dimensions and data integrity of
points_reprojectedare as expected before callingupsert_points. This can prevent potential runtime errors or data corruption.
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?
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>.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
@coderabbitaiin 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
@coderabbitaiin 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 generate interesting stats about this repository and render them as a table.@coderabbitai show all the console.log statements in this repository.@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.
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 as PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger a review. This is useful when automatic reviews are disabled for the repository.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai helpto get help.
Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
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.
@coderabbitai review
Codecov Report
Attention: Patch coverage is 76.88172% with 43 lines in your changes are missing coverage. Please review.
Project coverage is 73.85%. Comparing base (
443d410) to head (95071c1).
:exclamation: Current head 95071c1 differs from pull request most recent head 0c057c1. Consider uploading reports for the commit 0c057c1 to get more accurate results
| Files | Patch % | Lines |
|---|---|---|
| sleap/io/cameras.py | 71.42% | 42 Missing :warning: |
| sleap/gui/commands.py | 96.77% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## liezl/add-method-to-match-instances-across-views #1618 +/- ##
====================================================================================
+ Coverage 73.81% 73.85% +0.03%
====================================================================================
Files 135 135
Lines 24636 24807 +171
====================================================================================
+ Hits 18186 18322 +136
- Misses 6450 6485 +35
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Ordered by: cumulative time
List reduced from 5387 to 100 due to restriction <100>
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 11.447 11.447 runner.py:111(pytest_runtest_protocol)
17/11 0.000 0.000 11.447 1.041 _hooks.py:427(__call__)
17/11 0.000 0.000 11.447 1.041 _manager.py:103(_hookexec)
17/11 0.000 0.000 11.447 1.041 _callers.py:30(_multicall)
1 0.000 0.000 11.446 11.446 runner.py:119(runtestprotocol)
3 0.000 0.000 11.446 3.815 runner.py:219(call_and_report)
3 0.000 0.000 11.446 3.815 runner.py:247(call_runtest_hook)
3 0.000 0.000 11.446 3.815 runner.py:318(from_call)
3 0.000 0.000 11.446 3.815 runner.py:262(<lambda>)
1 0.000 0.000 11.427 11.427 runner.py:160(pytest_runtest_call)
1 0.000 0.000 11.427 11.427 python.py:1790(runtest)
1 0.000 0.000 11.427 11.427 python.py:187(pytest_pyfunc_call)
1 0.000 0.000 11.427 11.427 test_commands.py:1304(test_triangulate_session)
2 0.000 0.000 11.427 5.714 commands.py:617(triangulateSession)
2 0.000 0.000 11.427 5.714 commands.py:242(execute)
2 0.000 0.000 11.427 5.714 commands.py:109(execute)
2 0.000 0.000 11.416 5.708 commands.py:158(do_with_signal)
2 0.000 0.000 11.416 5.708 commands.py:3393(do_action)
2 0.000 0.000 11.416 5.708 commands.py:3766(get_instance_grouping_and_reprojected_coords)
2 0.000 0.000 11.416 5.708 commands.py:3998(calculate_error_per_frame)
2 0.023 0.012 11.416 5.708 commands.py:3858(_calculate_reprojection_error)
2 0.000 0.000 10.871 5.435 commands.py:4391(calculate_reprojected_points)
2 0.000 0.000 10.833 5.417 commands.py:4271(_calculate_reprojected_points)
2 0.000 0.000 10.509 5.255 triangulation.py:72(triangulate)
2 0.000 0.000 10.509 5.254 triangulation.py:177(<listcomp>)
4 0.012 0.003 10.509 2.627 cameras.py:1161(triangulate_optim)
6 0.000 0.000 8.176 1.363 dispatcher.py:388(_compile_for_args)
33/9 0.000 0.000 7.983 0.887 compiler.py:469(_compile_core)