Skip to content

Commit 1705da1

Browse files
authored
Compact show for BlockRange (#238)
* compact show for BlockRange * update docs * version bump to v0.16.24
1 parent b39635d commit 1705da1

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BlockArrays"
22
uuid = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
3-
version = "0.16.23"
3+
version = "0.16.24"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[deps]
2+
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
23
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
34

45
[compat]

docs/src/man/blockarrays.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ julia> view(A, Block(2)) .= [3,4]; A[Block(2)]
156156
4.0
157157
158158
julia> view(A, Block.(1:2))
159-
3-element view(::BlockVector{Float64, Vector{Vector{Float64}}, Tuple{BlockedUnitRange{ArrayLayouts.RangeCumsum{Int64, UnitRange{Int64}}}}}, BlockSlice(Block{1, Int64}[Block(1), Block(2)],1:1:3)) with eltype Float64 with indices 1:1:3:
159+
3-element view(::BlockVector{Float64, Vector{Vector{Float64}}, Tuple{BlockedUnitRange{ArrayLayouts.RangeCumsum{Int64, UnitRange{Int64}}}}}, BlockSlice(BlockRange(1:2),1:1:3)) with eltype Float64 with indices 1:1:3:
160160
1.0
161161
3.0
162162
4.0

src/blockindices.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ _in(b, ::Tuple{}, ::Tuple{}, ::Tuple{}) = b
387387
# We sometimes need intersection of BlockRange to return a BlockRange
388388
intersect(a::BlockRange{1}, b::BlockRange{1}) = BlockRange(intersect(a.indices[1], b.indices[1]))
389389

390+
Base.show(io::IO, br::BlockRange) = print(io, "BlockRange(", br.indices..., ")")
390391

391392
# needed for scalar-like broadcasting
392393

test/test_blockviews.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,14 @@ bview(a, b) = Base.invoke(view, Tuple{AbstractArray,Any}, a, b)
174174
W = view(A,Block.(1:2),Block(1))
175175
@test blocks(V) == blocks(A)[1:1,1:2]
176176
@test blocks(W) == blocks(A)[1:2,1:1]
177-
@test stringmime("text/plain", V) == "1×3 view(::BlockMatrix{$Int, Matrix{Matrix{$Int}}, $(typeof(axes(A)))}, BlockSlice(Block(1),1:1), BlockSlice(Block{1, $Int}[Block(1), Block(2)],1:1:3)) with eltype $Int with indices Base.OneTo(1)×1:1:3:\n 1 │ 2 3"
178-
@test stringmime("text/plain", W) == "3×1 view(::BlockMatrix{$Int, Matrix{Matrix{$Int}}, $(typeof(axes(A)))}, BlockSlice(Block{1, $Int}[Block(1), Block(2)],1:1:3), BlockSlice(Block(1),1:1)) with eltype $Int with indices 1:1:3×Base.OneTo(1):\n 1\n\n 4\n 7"
177+
Vi = parentindices(V)
178+
@test stringmime("text/plain", V) == "1×3 view(::BlockMatrix{$Int, Matrix{Matrix{$Int}}, "*
179+
"$(typeof(axes(A)))}, $(Vi[1]), $(Vi[2])) "*
180+
"with eltype $Int with indices $(axes(V,1))×$(axes(V,2)):\n 1 │ 2 3"
181+
Wi = parentindices(W)
182+
@test stringmime("text/plain", W) == "3×1 view(::BlockMatrix{$Int, Matrix{Matrix{$Int}}"*
183+
", $(typeof(axes(A)))}, $(Wi[1]), $(Wi[2])) "*
184+
"with eltype $Int with indices $(axes(W,1))×$(axes(W,2)):\n 1\n\n 4\n 7"
179185
end
180186

181187
@testset "getindex with BlockRange" begin

0 commit comments

Comments
 (0)