feat: Add trackTitles support to Piece class (Issue #44)#45
Conversation
Resolves Issue #44 Add support for the trackTitles attribute to enable custom labeling of instrument tracks in multi-track recordings. This feature is particularly useful for recordings with multiple instances of the same instrument (e.g., sarangi trios with "Lead Melody", "Harmony", and "Drone" labels). ## Changes: - Add 'trackTitles' to allowed parameters in Piece constructor - Initialize track_titles with automatic length synchronization - Add type validation (must be list of strings) - Include trackTitles in serialization (to_json) - Maintain backward compatibility (defaults to empty strings) ## Testing: - 9 comprehensive test cases covering: - Default initialization - Explicit values - Length synchronization (padding/truncation) - Type validation - Serialization round-trip - Real-world use cases (sarangi trio) - All 356 existing tests continue to pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
📦 Test Package Built Successfully! This PR has been automatically built and uploaded to TestPyPI for testing. 🔗 TestPyPI Link: https://test.pypi.org/project/idtap/ To test this version: pip install --index-url https://test.pypi.org/simple/ idtap✅ All tests passed and package builds successfully. |
|
@claude review |
|
Claude finished @jon-myers's task —— View job Code Review Complete ✅OverviewThis is a well-implemented feature that adds ✅ StrengthsCode Quality & Best Practices
Robust Implementation
Excellent Test Coverage
🔍 Minor ObservationsCode Quality
Performance Considerations
Security
🎯 Specific Code ReviewInitialization Logic (
|
| Category | Rating | Notes |
|---|---|---|
| Code Quality | ⭐⭐⭐⭐⭐ | Clean, readable, follows conventions |
| Test Coverage | ⭐⭐⭐⭐⭐ | Comprehensive, covers all cases |
| Performance | ⭐⭐⭐⭐⭐ | Minimal overhead, efficient |
| Security | ⭐⭐⭐⭐⭐ | No concerns, proper validation |
| Backward Compatibility | ⭐⭐⭐⭐⭐ | Fully maintained |
🚀 Recommendation
APPROVE - This is production-ready code that solves the stated problem effectively. The implementation is robust, well-tested, and maintains full backward compatibility. The feature will resolve the compatibility issue with the main IDTAP project while providing valuable functionality for multi-track recordings.
The code demonstrates excellent software engineering practices and would be a valuable addition to the codebase.
Summary
Implements support for the
trackTitlesattribute in thePiececlass, enabling custom labeling of instrument tracks for better identification in multi-track recordings.Resolves #44
Background
The main IDTAP project added
trackTitlesin commit 770c1ef4 (Sept 2024), but the Python API was not updated. This causedValueErrorwhen loading transcriptions containing thetrackTitlesattribute.Use Case
Particularly useful for recordings with multiple instances of the same instrument:
Implementation Details
1. Parameter Validation (
piece.py:217-224)'trackTitles'to allowed constructor parameters2. Type Validation (
piece.py:348-353)trackTitlesis a list3. Initialization (
piece.py:105-117)instrumentationlengthtrackTitlesfrom constructor4. Serialization (
piece.py:1336)trackTitlesinto_json()outputTesting
New Test Coverage (9 tests)
✅ Default initialization with empty strings
✅ Explicit values provided
✅ Length synchronization (shorter array → padded)
✅ Length synchronization (longer array → truncated)
✅ Type validation (non-list raises TypeError)
✅ Type validation (non-string items raise TypeError)
✅ Serialization round-trip preservation
✅ Empty string values handling
✅ Real-world sarangi trio use case
Test Results
Example Usage
Backward Compatibility
✅ Fully backward compatible
trackTitlescontinues to workChecklist
🤖 Generated with Claude Code