Skip to content

Commit e5e6742

Browse files
authored
Don't extend summary(::AbstractBlockArray) (#273)
* don't extend summary(::AbstractBlockArray) * fix uses of summary in docstests and tests
1 parent f6cb6ae commit e5e6742

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/abstractblockarray.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const AbstractBlockVecOrMat{T} = Union{AbstractBlockMatrix{T}, AbstractBlockVect
2323

2424
block2string(b, s) = string(join(map(string,b), '×'), "-blocked ", Base.dims2string(s))
2525
_block_summary(a) = string(block2string(blocksize(a), size(a)), " ", typeof(a))
26-
Base.summary(a::AbstractBlockArray) = _block_summary(a)
2726
_show_typeof(io, a) = show(io, typeof(a))
2827
function _block_summary(io, a)
2928
print(io, block2string(blocksize(a), size(a)))
@@ -84,7 +83,7 @@ specialize this method if they need to provide custom block bounds checking beha
8483
julia> A = BlockArray(rand(2,3), [1,1], [2,1]);
8584
8685
julia> blockcheckbounds(A, 3, 2)
87-
ERROR: BlockBoundsError: attempt to access 2×2-blocked 2×3 BlockMatrix{Float64, Matrix{Matrix{Float64}}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}} at block index [3,2]
86+
ERROR: BlockBoundsError: attempt to access 2×2-blocked 2×3 BlockMatrix{Float64} at block index [3,2]
8887
[...]
8988
```
9089
"""

test/test_blockarrays.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,15 +429,19 @@ end
429429
end
430430

431431
@testset "string" begin
432-
A = BlockArray(rand(4, 5), [1,3], [2,3]);
433432
buf = IOBuffer()
434-
Base.showerror(buf, BlockBoundsError(A, (3,2)))
435-
@test String(take!(buf)) == "BlockBoundsError: attempt to access 2×2-blocked 4×5 BlockMatrix{Float64, Matrix{Matrix{Float64}}, Tuple{BlockedUnitRange{Vector{$Int}}, BlockedUnitRange{Vector{$Int}}}} at block index [3,2]"
433+
A = BlockArray(rand(2,3), [1,1], [2,1]);
434+
summary(buf, A)
435+
s = String(take!(buf))
436+
@test s == summary(A)
436437

438+
A = BlockArray(rand(4, 5), [1,3], [2,3]);
439+
Base.showerror(buf, BlockBoundsError(A, (3,2)))
440+
@test String(take!(buf)) == "BlockBoundsError: attempt to access $(summary(A)) at block index [3,2]"
437441

438442
A = PseudoBlockArray(rand(4, 5), [1,3], [2,3]);
439443
Base.showerror(buf, BlockBoundsError(A, (3,2)))
440-
@test String(take!(buf)) == "BlockBoundsError: attempt to access 2×2-blocked 4×5 PseudoBlockMatrix{Float64, Matrix{Float64}, Tuple{BlockedUnitRange{Vector{$Int}}, BlockedUnitRange{Vector{$Int}}}} at block index [3,2]"
444+
@test String(take!(buf)) == "BlockBoundsError: attempt to access $(summary(A)) at block index [3,2]"
441445
end
442446

443447
@testset "replstring" begin

0 commit comments

Comments
 (0)