Skip to content

Commit a408d0b

Browse files
authored
Show for Tensorizer (#550)
1 parent 8d768e2 commit a408d0b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Multivariate/TensorSpace.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ factor(d::AbstractProductSpace,k) = factors(d)[k]
2424
# would be Tensorizer((Ones{Int}(∞), Fill(2,∞)))
2525

2626

27-
struct Tensorizer{DMS<:Tuple}
27+
struct Tensorizer{DMS<:Tuple{Vararg{AbstractVector{Int}}}}
2828
blocks::DMS
2929
end
3030

3131
const InfOnes = Ones{Int,1,Tuple{OneToInf{Int}}}
3232
const Tensorizer2D{AA, BB} = Tensorizer{Tuple{AA, BB}}
3333
const TrivialTensorizer{d} = Tensorizer{NTuple{d,InfOnes}}
3434

35+
show(io::IO, t::Tensorizer) = print(io, Tensorizer, "(", t.blocks, ")")
36+
3537
eltype(::Type{<:Tensorizer{<:Tuple{Vararg{Any,N}}}}) where {N} = NTuple{N,Int}
3638
dimensions(a::Tensorizer) = map(sum,a.blocks)
3739
length(a::Tensorizer) = reduce(*, dimensions(a)) # easier type-inference than mapreduce

test/show.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,9 @@
100100
C = cache(B)
101101
@test contains(repr(C), "Cached " * repr(B))
102102
end
103+
@testset "Tensorizer" begin
104+
o = Ones(Int,ℵ₀)
105+
t = ApproxFunBase.Tensorizer((o,o))
106+
@test repr(t) == "ApproxFunBase.Tensorizer($((o,o)))"
107+
end
103108
end

0 commit comments

Comments
 (0)