Skip to content

More compact show for block sparse arrays #42

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

Merged
merged 10 commits into from
Feb 10, 2025
Merged

More compact show for block sparse arrays #42

merged 10 commits into from
Feb 10, 2025

Conversation

mtfishman
Copy link
Member

@mtfishman mtfishman commented Feb 7, 2025

With this PR printing block sparse arrays looks like:

julia> a1 = BlockSparseArray{Float64}([2, 2])
2-blocked 4-element BlockSparseVector{Float64, Vector{Float64}, }:
 .
 .
 ─
 .
 .

julia> a2 = BlockSparseArray{Float64}([2, 2], [2, 2])
2×2-blocked 4×4 BlockSparseMatrix{Float64, Matrix{Float64}, }:
 .  .  │  .  .
 .  .  │  .  .
 ──────┼──────
 .  .  │  .  .
 .  .  │  .  .

julia> a2'
4×4 adjoint(::BlockSparseMatrix{Float64, Matrix{Float64}, …}) with eltype Float64 with indices BlockedOneTo([2, 4])×BlockedOneTo([2, 4]):
 .  .  │  .  .
 .  .  │  .  .
 ──────┼──────
 .  .  │  .  .
 .  .  │  .  .

julia> a3 = BlockSparseArray{Float64}([2, 2], [2, 2], [2, 2])
2×2×2-blocked 4×4×4 BlockSparseArray{Float64, 3, Array{Float64, 3}, }:
[:, :, 1] =
 .  .  .  .
 .  .  .  .
 .  .  .  .
 .  .  .  .

[:, :, 2] =
 .  .  .  .
 .  .  .  .
 .  .  .  .
 .  .  .  .

[:, :, 3] =
 .  .  .  .
 .  .  .  .
 .  .  .  .
 .  .  .  .

[:, :, 4] =
 .  .  .  .
 .  .  .  .
 .  .  .  .
 .  .  .  .

julia> PermutedDimsArray(a3, (3, 2, 1))
4×4×4 PermutedDimsArray(::BlockSparseArray{Float64, 3, Array{Float64, 3}, …}, (3, 2, 1)) with eltype Float64 with indices BlockedOneTo([2, 4])×BlockedOneTo([2, 4])×BlockedOneTo([2, 4]):
[:, :, 1] =
 .  .  .  .
 .  .  .  .
 .  .  .  .
 .  .  .  .

[:, :, 2] =
 .  .  .  .
 .  .  .  .
 .  .  .  .
 .  .  .  .

[:, :, 3] =
 .  .  .  .
 .  .  .  .
 .  .  .  .
 .  .  .  .

[:, :, 4] =
 .  .  .  .
 .  .  .  .
 .  .  .  .
 .  .  .  .

i.e. it suppresses printing the types of the block storage and axes (where it shows BlockSparseMatrix{Float64, Matrix{Float64}, …} rather than the contents of ), which can get very long, particularly for graded unit ranges.

Todo:

  • Add tests for Base.show, Base.summary, and TypeParameterAccessors.position.

Copy link

codecov bot commented Feb 8, 2025

Codecov Report

Attention: Patch coverage is 88.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 74.90%. Comparing base (2f14c41) to head (75342a2).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...stractblocksparsearray/abstractblocksparsearray.jl 76.92% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #42      +/-   ##
==========================================
+ Coverage   74.31%   74.90%   +0.59%     
==========================================
  Files          30       30              
  Lines        1059     1108      +49     
==========================================
+ Hits          787      830      +43     
- Misses        272      278       +6     
Flag Coverage Δ
docs 24.84% <0.00%> (-1.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mtfishman mtfishman changed the title [WIP] More compact show for block sparse arrays More compact show for block sparse arrays Feb 10, 2025
@mtfishman mtfishman marked this pull request as ready for review February 10, 2025 21:55
@mtfishman mtfishman requested review from ogauthe and lkdvos February 10, 2025 21:56
@mtfishman mtfishman merged commit 4943431 into main Feb 10, 2025
9 checks passed
@mtfishman mtfishman deleted the compact_show branch February 10, 2025 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants