Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ julia> v = GBVector{ComplexF32}(100)
julia> v = GBMatrix(ComplexF64[1, 2im, 3 + 4im]; fill = nothing)
3x1 GraphBLAS double complex matrix, full by col
3 entries, memory: 288 bytes
fill value: nothing

(1,1) 1 + 0i
(2,1) 0 + 2i
Expand Down
1 change: 1 addition & 0 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ julia> cohen(A), sandia(A)
julia> bfs_parents(A, 1, 5)
5x1 GraphBLAS int64_t matrix, bitmap by col
5 entries, memory: 288 bytes
fill value: nothing

(1,1) 0
(2,1) 1
Expand Down
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ true
julia> B = setfill(A, missing) # no-copy alias
1000x1000 GraphBLAS double complex matrix, hypersparse by row, ints: 32/32/32
no entries, memory: 256 bytes
fill value: missing

julia> B[1, 1]
missing
Expand Down
15 changes: 12 additions & 3 deletions src/abstractgbarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1019,14 +1019,23 @@ function Base.setindex!(
end

function Base.show(io::IO, ::MIME"text/plain", A::AbstractGBArray) #fallback printing
gxbprint(io, A)
str = gxbstring(A)
fill = getfill(A)
if !isequal(fill, defaultfill(storedeltype(A)))
# insert the fill value after the two GraphBLAS header lines, or append it
line = " fill value: $fill\n"
i = findfirst('\n', str)
i = i === nothing ? nothing : findnext('\n', str, i + 1)
str = i === nothing ? string(chomp(str), '\n', line) : str[1:i] * line * str[i+1:end]
end
print(io, str)
end

function Base.show(io::IO, A::AbstractGBArray)
gxbprint(io, A)
show(io, MIME"text/plain"(), A)
end
function Base.show(io::IOContext, A::AbstractGBArray)
gxbprint(io, A)
show(io, MIME"text/plain"(), A)
end


Expand Down
3 changes: 3 additions & 0 deletions test/gbarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
@test A'[1, 2] == 2
deleteat!(A, 1, 1)
@test A[1, 1] == getfill(A)
# #104: non-default fill shows up in show
@test !occursin("fill value", sprint(show, MIME"text/plain"(), A))
@test occursin("fill value: 17", sprint(show, MIME"text/plain"(), setfill(A, 17)))
end
@testset "sparse" begin
#Construction and indexing correct for sparse matrices
Expand Down
Loading