Skip to content

Commit 0e43f5a

Browse files
committed
rework diagonal tensor show
1 parent cdab73b commit 0e43f5a

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/tensors/diagonal.jl

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -335,23 +335,13 @@ end
335335

336336
# Show
337337
#------
338-
function Base.summary(io::IO, t::DiagonalTensorMap)
339-
return print(io, "DiagonalTensorMap(", space(t), ")")
338+
function type_repr(::Type{DiagonalTensorMap{T, S, A}}) where {T, S, A}
339+
return "DiagonalTensorMap{$T, $(type_repr(S)), $A}"
340340
end
341-
function Base.show(io::IO, t::DiagonalTensorMap)
342-
summary(io, t)
343-
get(io, :compact, false) && return nothing
344-
println(io, ":")
345-
346-
if sectortype(t) == Trivial
347-
Base.print_array(io, Diagonal(t.data))
348-
println(io)
349-
else
350-
for (c, b) in blocks(t)
351-
println(io, "* Data for sector ", c, ":")
352-
Base.print_array(io, b)
353-
println(io)
354-
end
355-
end
341+
function Base.showarg(io::IO, t::DiagonalTensorMap, toplevel::Bool)
342+
!toplevel && print(io, "::")
343+
print(io, type_repr(typeof(t)))
356344
return nothing
357345
end
346+
Base.show(io::IO, t::DiagonalTensorMap) =
347+
print(io, type_repr(typeof(t)), "(", t.data, ", ", space(t, 1), ")")

0 commit comments

Comments
 (0)