Simplify the Features infrastructure and add AnnotatorManager#96
Merged
cmalinmayor merged 34 commits into2-feature-infrastructurefrom Oct 23, 2025
Merged
Simplify the Features infrastructure and add AnnotatorManager#96cmalinmayor merged 34 commits into2-feature-infrastructurefrom
cmalinmayor merged 34 commits into2-feature-infrastructurefrom
Conversation
This comprehensive refactor improves test maintainability and reduces code duplication across the test suite while maintaining 100% test coverage (181 tests passing). ## Test Infrastructure Improvements ### Added Feature Constants (conftest.py) - FEATURES_WITH_SEG = ["pos", "area", "iou"] - FEATURES_NO_SEG = ["pos"] - SOLUTION_FEATURES_WITH_SEG = ["pos", "area", "iou", "tracklet_id"] - SOLUTION_FEATURES_NO_SEG = ["pos", "tracklet_id"] - Ensures consistency across all test files and eliminates magic lists ### Added Factory Fixtures - get_tracks(ndim, with_seg, is_solution): Unified tracks creation - Automatically selects correct graph and segmentation fixtures - Automatically applies appropriate feature constants - Deep copies graphs to prevent fixture pollution - get_graph(ndim, with_features): Simplified graph selection - with_features options: "clean", "position", "computed" - Eliminates 15+ instances of manual graph fixture selection - get_segmentation(ndim): Simplified segmentation selection - Eliminates 12+ instances of conditional segmentation logic ## Test File Updates ### Refactored with Factory Fixtures - All action tests (test_add_delete_edge, test_add_delete_nodes, etc.) - All annotator tests (43 tests across 4 test files) - All user action tests - Import/export tests (test_export_to_geff, test_internal_format) - Data model tests (test_solution_tracks, test_tracks) ### Code Patterns Eliminated - "seg = segmentation_2d if ndim == 3 else segmentation_3d" (12+ instances) - Manual graph fixture selection based on ndim (15+ instances) - Inconsistent existing_features specifications ## Source Code Changes - Fixed edge case in add_delete_edge.py for proper edge removal handling - Added validation in add_delete_node.py for node attribute consistency ## Impact - Improved test readability and maintainability - Reduced code duplication by ~100 lines - Centralized test configuration in conftest.py - Easier to add new tests following established patterns - All 181 tests passing, 6 skipped (intentional)
Refactor test suite with factory fixtures and feature constants
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 2-feature-infrastructure #96 +/- ##
============================================================
- Coverage 91.37% 90.59% -0.79%
============================================================
Files 35 39 +4
Lines 1554 1659 +105
============================================================
+ Hits 1420 1503 +83
- Misses 134 156 +22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Closes #94