@@ -161,16 +161,15 @@ TensorKit.infimum(V::S, W::S) where {S <: SumSpace} = infimum(⊕(V), ⊕(W))
161161TensorKit. supremum (V:: S , W:: S ) where {S <: SumSpace } = supremum (⊕ (V), ⊕ (W))
162162TensorKit. ominus (V:: S , W:: S ) where {S <: SumSpace } = ominus (⊕ (V), ⊕ (W))
163163
164- TensorKit. oplus (V:: SumSpace{S} ) where {S} = reduce (⊕ , V. spaces; init = isdual (V) ? zero (S)' : zero (S))
164+ TensorKit. oplus (V:: SumSpace{S} ) where {S} = reduce (⊕ , V. spaces; init = isdual (V) ? zerospace (S)' : zerospace (S))
165165TensorKit. oplus (V1:: SumSpace{S} , V2:: SumSpace{S} ...) where {S} = mapreduce (⊕ , ⊕ , (V1, V2... ))
166166
167167function TensorKit. fuse (V1:: S , V2:: S ) where {S <: SumSpace }
168168 return SumSpace (vec ([fuse (v1, v2) for (v1, v2) in Base. product (V1. spaces, V2. spaces)]))
169169end
170170
171- Base. oneunit (S:: Type{<:SumSpace} ) = SumSpace (oneunit (eltype (S)))
172- Base. zero (V:: SumSpace{S} ) where {S} = SumSpace {S} (; dual = isdual (V))
173- Base. zero (:: Type{SumSpace{S}} ) where {S} = SumSpace {S} ()
171+ TensorKit. unitspace (S:: Type{<:SumSpace} ) = SumSpace (TensorKit. unitspace (eltype (S)))
172+ TensorKit. zerospace (:: Type{SumSpace{S}} ) where {S} = SumSpace {S} ()
174173
175174# Promotion and conversion
176175# ------------------------
@@ -228,19 +227,40 @@ function Base.show(io::IO, V::SumSpace)
228227 end
229228
230229 limited = get (io, :limited , true )
230+ ioc = IOContext (io, :compact => true )
231231 if limited && length (V) > SUMSPACE_SHOW_LIMIT[]
232232 ax = axes (V. spaces, 1 )
233233 f, l = first (ax), last (ax)
234234 h = SUMSPACE_SHOW_LIMIT[] ÷ 2
235- Base. show_delim_array (io , V. spaces, " (" , " ⊞" , " " , false , f, f + h)
235+ Base. show_delim_array (ioc , V. spaces, " (" , " ⊞" , " " , false , f, f + h)
236236 print (io, " ⊞ ⋯ ⊞ " )
237- Base. show_delim_array (io , V. spaces, " " , " ⊞" , " )" , false , l - h, l)
237+ Base. show_delim_array (ioc , V. spaces, " " , " ⊞" , " )" , false , l - h, l)
238238 else
239- Base. show_delim_array (io , V. spaces, " (" , " ⊞" , " )" , false )
239+ Base. show_delim_array (ioc , V. spaces, " (" , " ⊞" , " )" , false )
240240 end
241241 return nothing
242242end
243243
244+ function Base. show (io:: IO , :: MIME"text/plain" , V:: SumSpace )
245+ # print small summary, e.g.: l-element SumSpace(Vect[I](…)) of dim d
246+ l = length (V. spaces)
247+ d = dim (V)
248+ print (io, l, " -element ⊞(::" , TK. type_repr (eltype (V)), " …)" )
249+ isdual (V) && print (io, " '" )
250+ print (io, " of dim " , d)
251+
252+ compact = get (io, :compact , false ):: Bool
253+ (iszero (d) || compact) && return nothing
254+
255+ # print detailed space information - hijack Base.Vector printing
256+ print (io, " :\n " )
257+ print_data = V. spaces
258+ ioc = IOContext (io, :typeinfo => eltype (print_data))
259+ Base. print_matrix (ioc, print_data)
260+
261+ return nothing
262+ end
263+
244264# TensorMapSumSpace
245265# -----------------
246266# function TensorKit.fusionblockstructure(
0 commit comments