Skip to content

More general printing #119

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 12 commits into from
May 24, 2020
Merged

More general printing #119

merged 12 commits into from
May 24, 2020

Conversation

dlfivefifty
Copy link
Member

This generalises block-printing to include, for example, views of BlockArray:

julia> B = BlockMatrix(randn(6,6), 1:3, 1:3)
3×3-blocked 6×6 BlockArray{Float64,2}:
  0.1457570.246326    0.534004-0.76561    1.14499   -1.96236  
 ───────────┼─────────────────────────┼──────────────────────────────────
 -0.494542-1.02236     0.7017-1.17902   -1.16601   -0.904528 
  0.832341-0.0572088  -0.984644-0.730904   0.433201  -1.39913  
 ───────────┼─────────────────────────┼──────────────────────────────────
 -1.08485-0.522733    0.4293312.43006   -2.25876    0.40058  
  0.2694360.879403   -0.2249481.83561    0.466786   0.0546217
  1.16865-0.685722    2.069240.377139  -2.12384   -0.303557 

julia> view(B,Block.(1:2),Block.(1:2))
3×3 view(::BlockArray{Float64,2,Array{Array{Float64,2},2},Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}}}, BlockSlice(Block{1,Int64}[Block(1), Block(2)],1:1:3), BlockSlice(Block{1,Int64}[Block(1), Block(2)],1:1:3)) with eltype Float64 with indices 1:1:3×1:1:3:
  0.1457570.246326    0.534004
 ───────────┼───────────────────────
 -0.494542-1.02236     0.7017  
  0.832341-0.0572088  -0.984644

julia> B'
6×6 Adjoint{Float64,BlockArray{Float64,2,Array{Array{Float64,2},2},Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}}}} with indices 1:1:6×1:1:6:
  0.145757-0.494542   0.832341-1.08485    0.269436    1.16865 
 ───────────┼─────────────────────────┼──────────────────────────────────
  0.246326-1.02236   -0.0572088-0.522733   0.879403   -0.685722
  0.5340040.7017    -0.9846440.429331  -0.224948    2.06924 
 ───────────┼─────────────────────────┼──────────────────────────────────
 -0.76561-1.17902   -0.7309042.43006    1.83561     0.377139
  1.14499-1.16601    0.433201-2.25876    0.466786   -2.12384 
 -1.96236-0.904528  -1.399130.40058    0.0546217  -0.303557

Note it automatically works with LazyArrays.jl:

julia> BroadcastMatrix(exp,B)
6×6 BroadcastArray{Float64,2,typeof(exp),Tuple{BlockArray{Float64,2,Array{Array{Float64,2},2},Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}}}}} with indices 1:1:6×1:1:6:
 1.156921.27932   1.705750.46505   3.14242   0.140527
 ──────────┼──────────────────────┼───────────────────────────────
 0.609850.359745  2.017180.30758   0.311606  0.404733
 2.298690.944397  0.3735720.481474  1.54219   0.24681 
 ──────────┼──────────────────────┼───────────────────────────────
 0.3379510.592898  1.5362311.3596    0.10448   1.49269 
 1.309232.40946   0.7985576.26895   1.59486   1.05614 
 3.217650.503726  7.918761.45811   0.119572  0.738188

@codecov
Copy link

codecov bot commented May 24, 2020

Codecov Report

Merging #119 into master will increase coverage by 0.35%.
The diff coverage is 86.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #119      +/-   ##
==========================================
+ Coverage   85.24%   85.59%   +0.35%     
==========================================
  Files          15       15              
  Lines         935      965      +30     
==========================================
+ Hits          797      826      +29     
- Misses        138      139       +1     
Impacted Files Coverage Δ
src/BlockArrays.jl 100.00% <ø> (ø)
src/blockarrayinterface.jl 100.00% <ø> (ø)
src/blockindices.jl 62.58% <63.63%> (+2.29%) ⬆️
src/blockbroadcast.jl 79.48% <88.88%> (+0.03%) ⬆️
src/blocklinalg.jl 91.05% <90.00%> (+1.58%) ⬆️
src/blockarray.jl 97.18% <100.00%> (ø)
src/blocks.jl 88.00% <100.00%> (+1.04%) ⬆️
src/pseudo_blockarray.jl 89.38% <100.00%> (+0.09%) ⬆️
src/show.jl 96.72% <100.00%> (+0.16%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 42ae241...aee1419. Read the comment docs.

@dlfivefifty dlfivefifty changed the title WIP: More general printing More general printing May 24, 2020
@dlfivefifty dlfivefifty merged commit b963b13 into master May 24, 2020
@dlfivefifty dlfivefifty deleted the dl/betterprint branch May 24, 2020 19:02
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.

1 participant