diff --git a/src/spaces/gradedspace.jl b/src/spaces/gradedspace.jl index 5e0d76674..b319abcba 100644 --- a/src/spaces/gradedspace.jl +++ b/src/spaces/gradedspace.jl @@ -200,7 +200,7 @@ end Base.summary(io::IO, V::GradedSpace) = print(io, type_repr(typeof(V))) function Base.show(io::IO, V::GradedSpace) - opn = (get(io, :typeinfo, Any)::DataType == typeof(V) ? "" : type_repr(typeof(V))) + opn = (get(io, :typeinfo, Any)::Type == typeof(V) ? "" : type_repr(typeof(V))) opn *= "(" if isdual(V) cls = ")'" diff --git a/src/tensors/abstracttensor.jl b/src/tensors/abstracttensor.jl index 69fdce784..393bd905e 100644 --- a/src/tensors/abstracttensor.jl +++ b/src/tensors/abstracttensor.jl @@ -644,20 +644,26 @@ function Base.summary(io::IO, t::AbstractTensorMap) end # Human-readable: -function Base.show(io::IO, ::MIME"text/plain", t::AbstractTensorMap) - # 1) show summary: typically d₁×d₂×… ← d₃×d₄×… $(typeof(t)): +function Base.show(io::IO, mime::MIME"text/plain", t::AbstractTensorMap) + # 1) show summary: typically d₁×d₂×… ← d₃×d₄×… $(typeof(t)) summary(io, t) - println(io, ":") + # case without `\n`: + if get(io, :compact, true) + print(io, "(…, ") + show(io, mime, space(t)) + print(io, ')') + return nothing + end + + # case with `\n` # 2) show spaces - # println(io, " space(t):") + println(io, ':') println(io, " codomain: ", codomain(t)) println(io, " domain: ", domain(t)) # 3) [optional]: show data - get(io, :compact, true) && return nothing - ioc = IOContext(io, :typeinfo => sectortype(t)) println(io, "\n\n blocks: ") - show_blocks(io, MIME"text/plain"(), blocks(t)) + show_blocks(io, mime, blocks(t)) return nothing end diff --git a/test/symmetries/spaces.jl b/test/symmetries/spaces.jl index a952d4b6b..ede4ae52f 100644 --- a/test/symmetries/spaces.jl +++ b/test/symmetries/spaces.jl @@ -454,10 +454,10 @@ end @timedtestset "show and friends" begin V = U1Space(i => 1 for i in 1:3) - @test string(V) == "Rep[U₁](1 => 1, 2 => 1, 3 => 1)" - @test string(V') == "Rep[U₁](1 => 1, 2 => 1, 3 => 1)'" - @test sprint((x, y) -> show(x, MIME"text/plain"(), y), V) == "Rep[U₁](…) of dim 3:\n 1 => 1\n 2 => 1\n 3 => 1" - @test sprint((x, y) -> show(x, MIME"text/plain"(), y), V') == "Rep[U₁](…)' of dim 3:\n 1 => 1\n 2 => 1\n 3 => 1" + @test string(V) == "$(type_repr(typeof(V)))(1 => 1, 2 => 1, 3 => 1)" + @test string(V') == "$(type_repr(typeof(V)))(1 => 1, 2 => 1, 3 => 1)'" + @test sprint((x, y) -> show(x, MIME"text/plain"(), y), V) == "$(type_repr(typeof(V)))(…) of dim 3:\n 1 => 1\n 2 => 1\n 3 => 1" + @test sprint((x, y) -> show(x, MIME"text/plain"(), y), V') == "$(type_repr(typeof(V)))(…)' of dim 3:\n 1 => 1\n 2 => 1\n 3 => 1" end TensorKit.empty_globalcaches!()