Closed roomrys closed 7 months ago
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.
File Path | Change Summary |
---|---|
sleap/io/cameras.py |
Updated imports, added triangulate import, included new types from sleap.types . |
sleap/gui/commands.py sleap/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. π πΎπΈ
tests/fixtures/datasets.py (1)
`283-288`: The new fixture `multiview_min_session_user_labels` correctly 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 include `InstanceGroup` and `FrameGroup`, which are necessary for the new functionalities being tested. --- `292-339`: The function `create_instance_group` has 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 test `test_instance_group` effectively checks the functionality of the `InstanceGroup` data 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! The `Point` class implementation is clear and well-defined. --- Line range hint `75-110`: LGTM! The `PredictedPoint` class correctly extends the `Point` class with additional functionality for handling prediction scores. --- Line range hint `118-183`: LGTM! The `PointArray` class provides necessary functionality for handling arrays of `Point` objects efficiently. --- Line range hint `185-209`: LGTM! The `PredictedPointArray` class correctly extends `PointArray` to handle `PredictedPoint` objects, maintaining consistency in the API. --- Line range hint `211-235`: LGTM! The `Track` class implementation is straightforward and provides essential functionality for tracking objects across frames. --- `500-505`: > :memo: **NOTE** > This 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 `Instance` class are well-implemented and cover a wide range of functionalities required for managing instances in SLEAP. --- Line range hint `1654-1791`: LGTM! The `PredictedInstance` class correctly extends the `Instance` class to handle additional attributes and functionalities specific to predicted instances. --- Line range hint `1793-2428`: LGTM! The `LabeledFrame` class 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 where `instance_group` is `None` more explicitly. It might be beneficial to add a specific error message or handling logic when `instance_group` is `None`, as this could indicate a deeper issue with the data or assumptions being made. --- `3444-3449`: Ensure that the `triangulate` function handles exceptions or errors gracefully. --- `3458-3465`: Validate the dimensions and data integrity of `points_reprojected` before updating. Consider adding checks to ensure that the dimensions and data integrity of `points_reprojected` are as expected before calling `upsert_points`. This can prevent potential runtime errors or data corruption.
@coderabbitai review
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: |
: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)
Description
This PR adds and implements the
InstanceGroup
datastructure and should be used to updateInstanceGroup
.Types of changes
Does this address any currently open issues?
[list open issues here]
Outside contributors checklist
Thank you for contributing to SLEAP!
:heart:
Summary by CodeRabbit
Summary by CodeRabbit
Refactor
Tests
InstanceGroup
andFrameGroup
data structures.