Skip to content

Commit 5b1e01f

Browse files
committed
Add show for Diagonal
1 parent fd9cb9f commit 5b1e01f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/tensors/diagonal.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,26 @@ for f in
315315
:log, :asin, :acos, :acosh, :atanh, :acoth)
316316
@eval Base.$f(d::DiagonalTensorMap) = DiagonalTensorMap($f.(d.data), d.domain)
317317
end
318+
319+
# Show
320+
#------
321+
function Base.summary(io::IO, t::DiagonalTensorMap)
322+
return print(io, "DiagonalTensorMap(", space(t), ")")
323+
end
324+
function Base.show(io::IO, t::DiagonalTensorMap)
325+
summary(io, t)
326+
get(io, :compact, false) && return nothing
327+
println(io, ":")
328+
329+
if sectortype(t) == Trivial
330+
Base.print_array(io, Diagonal(t.data))
331+
println(io)
332+
else
333+
for (c, b) in blocks(t)
334+
println(io, "* Data for sector ", c, ":")
335+
Base.print_array(io, b)
336+
println(io)
337+
end
338+
end
339+
return nothing
340+
end

0 commit comments

Comments
 (0)