Skip to content

Commit 5c36967

Browse files
committed
improve display
1 parent 71cd86a commit 5c36967

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,18 @@ struct GradedOneTo{T,BlockLasts<:Vector{T}} <: AbstractGradedUnitRange{T,BlockLa
5353
end
5454

5555
function Base.show(io::IO, mimetype::MIME"text/plain", g::AbstractGradedUnitRange)
56-
v = blocklabels(g) .=> Int.(blocklengths(g))
57-
println(typeof(g))
58-
return show(io, mimetype, v)
56+
v = map(blocks(g)) do b
57+
label(b) => unlabel(first(b)):unlabel(last(b))
58+
end
59+
println(io, typeof(g))
60+
return print(join(repr.(v), '\n'))
61+
end
62+
63+
function Base.show(io::IO, g::AbstractGradedUnitRange)
64+
v = map(blocks(g)) do b
65+
label(b) => unlabel(first(b)):unlabel(last(b))
66+
end
67+
return print(io, nameof(typeof(g)), '[', join(repr.(v), ", "), ']')
5968
end
6069

6170
# == is just a range comparison that ignores labels. Need dedicated function to check equality.

0 commit comments

Comments
 (0)