-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement matrix truncation for latex to enhance the display of large matrices #26284
base: master
Are you sure you want to change the base?
Implement matrix truncation for latex to enhance the display of large matrices #26284
Conversation
…ting The `_print_matrix_contents` method now includes options for compactifying and setting maximum visible rows and columns, providing a more readable representation. This improvement prevents printing slowdowns for large matrices and improves overall user experience. This modification shall solve sympy#16251.
✅ Hi, I am the SymPy bot. I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.13. Click here to see the pull request description that was parsed.
|
Benchmark results from GitHub Actions Lower numbers are good, higher numbers are bad. A ratio less than 1 Significantly changed benchmark results (PR vs master) Significantly changed benchmark results (master vs previous release) | Change | Before [a00718ba] | After [24792d5f] | Ratio | Benchmark (Parameter) |
|----------|----------------------|---------------------|---------|----------------------------------------------------------------------|
| - | 68.6±0.5ms | 44.3±0.2ms | 0.65 | integrate.TimeIntegrationRisch02.time_doit(10) |
| - | 66.5±1ms | 43.8±0.2ms | 0.66 | integrate.TimeIntegrationRisch02.time_doit_risch(10) |
| + | 18.5±0.5μs | 30.0±0.5μs | 1.62 | integrate.TimeIntegrationRisch03.time_doit(1) |
| - | 5.20±0.02ms | 2.90±0.03ms | 0.56 | logic.LogicSuite.time_load_file |
| - | 72.2±0.6ms | 28.4±0.2ms | 0.39 | polys.TimeGCD_GaussInt.time_op(1, 'dense') |
| - | 25.4±0.4ms | 16.7±0.05ms | 0.66 | polys.TimeGCD_GaussInt.time_op(1, 'expr') |
| - | 73.0±0.9ms | 28.6±0.2ms | 0.39 | polys.TimeGCD_GaussInt.time_op(1, 'sparse') |
| - | 249±2ms | 123±0.9ms | 0.49 | polys.TimeGCD_GaussInt.time_op(2, 'dense') |
| - | 252±3ms | 123±2ms | 0.49 | polys.TimeGCD_GaussInt.time_op(2, 'sparse') |
| - | 643±9ms | 364±8ms | 0.57 | polys.TimeGCD_GaussInt.time_op(3, 'dense') |
| - | 643±9ms | 368±2ms | 0.57 | polys.TimeGCD_GaussInt.time_op(3, 'sparse') |
| - | 483±8μs | 282±2μs | 0.58 | polys.TimeGCD_LinearDenseQuadraticGCD.time_op(1, 'dense') |
| - | 1.75±0ms | 1.04±0.01ms | 0.59 | polys.TimeGCD_LinearDenseQuadraticGCD.time_op(2, 'dense') |
| - | 5.78±0.03ms | 3.08±0.01ms | 0.53 | polys.TimeGCD_LinearDenseQuadraticGCD.time_op(3, 'dense') |
| - | 448±2μs | 225±1μs | 0.5 | polys.TimeGCD_QuadraticNonMonicGCD.time_op(1, 'dense') |
| - | 1.44±0.02ms | 654±20μs | 0.46 | polys.TimeGCD_QuadraticNonMonicGCD.time_op(2, 'dense') |
| - | 4.80±0.09ms | 1.63±0.01ms | 0.34 | polys.TimeGCD_QuadraticNonMonicGCD.time_op(3, 'dense') |
| - | 374±2μs | 206±0.8μs | 0.55 | polys.TimeGCD_SparseGCDHighDegree.time_op(1, 'dense') |
| - | 2.39±0.05ms | 1.22±0.01ms | 0.51 | polys.TimeGCD_SparseGCDHighDegree.time_op(3, 'dense') |
| - | 9.84±0.1ms | 4.30±0.03ms | 0.44 | polys.TimeGCD_SparseGCDHighDegree.time_op(5, 'dense') |
| - | 356±1μs | 169±2μs | 0.48 | polys.TimeGCD_SparseNonMonicQuadratic.time_op(1, 'dense') |
| - | 2.50±0.03ms | 893±0.4μs | 0.36 | polys.TimeGCD_SparseNonMonicQuadratic.time_op(3, 'dense') |
| - | 9.70±0.06ms | 2.68±0.01ms | 0.28 | polys.TimeGCD_SparseNonMonicQuadratic.time_op(5, 'dense') |
| - | 1.02±0.01ms | 424±1μs | 0.42 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'dense') |
| - | 1.74±0.02ms | 516±4μs | 0.3 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'sparse') |
| - | 5.85±0.03ms | 1.79±0.01ms | 0.31 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'dense') |
| - | 8.35±0.03ms | 1.52±0ms | 0.18 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'sparse') |
| - | 285±0.9μs | 65.0±0.8μs | 0.23 | polys.TimePREM_QuadraticNonMonicGCD.time_op(1, 'sparse') |
| - | 3.42±0.02ms | 396±2μs | 0.12 | polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'dense') |
| - | 3.92±0.03ms | 282±2μs | 0.07 | polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'sparse') |
| - | 6.98±0.08ms | 1.26±0.01ms | 0.18 | polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'dense') |
| - | 8.65±0.07ms | 858±3μs | 0.1 | polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'sparse') |
| - | 5.04±0.03ms | 2.99±0.01ms | 0.59 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(2, 'sparse') |
| - | 12.0±0.09ms | 6.55±0.1ms | 0.54 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'dense') |
| - | 22.4±0.2ms | 9.12±0.09ms | 0.41 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'sparse') |
| - | 5.16±0.02ms | 869±4μs | 0.17 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(1, 'sparse') |
| - | 12.7±0.1ms | 7.10±0.03ms | 0.56 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(2, 'sparse') |
| - | 101±0.4ms | 25.5±0.1ms | 0.25 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'dense') |
| - | 165±2ms | 54.3±0.1ms | 0.33 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'sparse') |
| - | 174±3μs | 111±0.9μs | 0.64 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(1, 'dense') |
| - | 359±0.9μs | 217±1μs | 0.61 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(1, 'sparse') |
| - | 4.25±0.1ms | 838±6μs | 0.2 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'dense') |
| - | 5.25±0.08ms | 384±2μs | 0.07 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'sparse') |
| - | 19.7±0.2ms | 2.81±0ms | 0.14 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'dense') |
| - | 22.5±0.1ms | 637±5μs | 0.03 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'sparse') |
| - | 482±2μs | 136±1μs | 0.28 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(1, 'sparse') |
| - | 4.51±0.1ms | 623±3μs | 0.14 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'dense') |
| - | 5.23±0.03ms | 140±0.3μs | 0.03 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'sparse') |
| - | 13.1±0.06ms | 1.28±0ms | 0.1 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'dense') |
| - | 13.5±0.4ms | 141±1μs | 0.01 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'sparse') |
| - | 132±3μs | 75.5±0.3μs | 0.57 | solve.TimeMatrixOperations.time_rref(3, 0) |
| - | 249±1μs | 88.4±0.4μs | 0.35 | solve.TimeMatrixOperations.time_rref(4, 0) |
| - | 24.0±0.06ms | 10.0±0.06ms | 0.42 | solve.TimeSolveLinSys189x49.time_solve_lin_sys |
| - | 27.8±0.4ms | 15.4±0.1ms | 0.55 | solve.TimeSparseSystem.time_linsolve_Aaug(20) |
| - | 54.4±0.2ms | 24.4±0.4ms | 0.45 | solve.TimeSparseSystem.time_linsolve_Aaug(30) |
| - | 27.9±0.1ms | 15.3±0.09ms | 0.55 | solve.TimeSparseSystem.time_linsolve_Ab(20) |
| - | 54.7±0.4ms | 24.6±0.1ms | 0.45 | solve.TimeSparseSystem.time_linsolve_Ab(30) |
Full benchmark results can be found as artifacts in GitHub Actions |
References to other Issues or PRs
Fixes #16251
Brief description of what is fixed or changed
The
_print_matrix_contents
method now includes options for compactifying and setting maximum visible rows and columns, providing a more readable representation. This improvement prevents printing slowdowns for large matrices and improves overall user experience.Basically, the method looks if the number of rows or number of columns exceeds certain thresholds, which are predefined in the
_settings
dictionary under the namesmat_visible_rows
andmat_visible_cols
respectively, with15
as a default value. If so, the method avoids iterating over all elements of the matrix and adds dots to imply compaction.The compaction feature is also predefined in
_settings
dictionary with default valueTrue
to avoid large matrix printing slowdown.Here is the behavior after enabling the compaction feature:
And here is the behavior with it:
Also, compaction of rows and cols are independent based on the dimension of each. The following two examples illustrates this better:
Finally, if the matrix dimensions are small (below thresholds) in both axes then no compaction takes place like so :
Other comments
Release Notes