harbor run -t openthoughts/tasktrove-mix-baseline-uniform-v2-mix-baseline-uniform-1338harbor download openthoughts/tasktrove-mix-baseline-uniform-v2-mix-baseline-uniform-1338Task Description: Implement SparseMatrix Functionality
You are required to implement the functionality of the SparseMatrix class located in the /app/ directory in such a way that it passes all the provided tests in the given test code. The SparseMatrix class should support the following features:
Matrix Creation:
SparseMatrix(rows, cols)) with optional initialization values.Element Access and Assignment:
__getitem__ and __setitem__) to access and modify elements in the matrix, including support for single indices and tuples for 2D access.Matrix Operations:
transpose, trace, and determinant calculation.Matrix Properties:
Error Handling:
ValueError, TypeError, IndexError, ShapeError).Matrix Modifications:
row_join, col_join, and fill to manipulate the matrix's structure.Advanced Features:
Performance Considerations:
The implementation should ensure that all assertions in the provided test code are satisfied, leading to the successful passing of all tests when executed. Ensure the code is well-structured and adheres to Python best practices.