Skip to content

Commit 89908fa

Browse files
committed
retry gradedspace printing
1 parent a10de49 commit 89908fa

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
99
MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4"
1010
OhMyThreads = "67456a42-1dca-4109-a031-0a68de7e3ad5"
1111
PackageExtensionCompat = "65ce6f38-6b18-4e1d-a461-8949797d7930"
12+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1213
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1314
ScopedValues = "7e506255-f358-4e82-b7e4-beb19740aa63"
1415
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
@@ -36,6 +37,7 @@ LinearAlgebra = "1"
3637
MatrixAlgebraKit = "0.5.0"
3738
OhMyThreads = "0.8.0"
3839
PackageExtensionCompat = "1"
40+
Printf = "1"
3941
Random = "1"
4042
ScopedValues = "1.3.0"
4143
Strided = "2"

src/TensorKit.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ using Base: @boundscheck, @propagate_inbounds, @constprop,
127127
tuple_type_head, tuple_type_tail, tuple_type_cons,
128128
SizeUnknown, HasLength, HasShape, IsInfinite, EltypeUnknown, HasEltype
129129
using Base.Iterators: product, filter
130+
using Printf: @sprintf
130131

131132
using LinearAlgebra: LinearAlgebra, BlasFloat
132133
using LinearAlgebra: norm, dot, normalize, normalize!, tr,

src/spaces/gradedspace.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ function supremum(V₁::GradedSpace{I}, V₂::GradedSpace{I}) where {I <: Sector
198198
end
199199

200200
function Base.summary(io::IO, V::GradedSpace)
201-
print(io, dim(V), "-dimensional ")
201+
d = dim(V)
202+
dstr = d isa Int ? string(d) : @sprintf "%.2f" d
203+
print(io, dstr, "-dimensional ")
202204
isdual(V) && print(io, "dual ")
203205
print(io, type_repr(typeof(V)))
204206
return nothing
@@ -250,6 +252,17 @@ function Base.show(io::IO, V::GradedSpace)
250252
return nothing
251253
end
252254

255+
function Base.show(io::IO, ::MIME"text/plain", V::GradedSpace)
256+
summary(io, V)
257+
iszero(dim(V)) && return nothing
258+
println(io, ":")
259+
print(io, " ")
260+
ioc = IOContext(io, :typeinfo => typeof(V))
261+
show(ioc, V)
262+
return nothing
263+
end
264+
265+
253266
struct SpaceTable end
254267
"""
255268
const Vect

0 commit comments

Comments
 (0)