Skip to content

Commit c2dd5ca

Browse files
authored
reintroduce compact show for operators (#478)
* reintroduce compact show for operators * tests for compact show * Fix test
1 parent c5eaf34 commit c2dd5ca

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunBase"
22
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
3-
version = "0.8.32"
3+
version = "0.8.33"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/show.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ end
9999
function show(io::IO, mimetype::MIME"text/plain", @nospecialize(B::Operator); header::Bool=true)
100100
header && summary(io, B)
101101

102+
if !haskey(io, :compact) && size(B, 2) > 1
103+
io = IOContext(io, :compact => true)
104+
end
105+
102106
if !isambiguous(domainspace(B)) && eltype(B) <: Number
103107
println(io)
104108
sz1, sz2 = min.(size(B), 10)

test/show.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@
7474
s = summary(A)
7575
@test startswith(s, "ConstantOperator")
7676
end
77+
@testset "compact show" begin
78+
p = [1+1e-8];
79+
M = Multiplication(Fun(PointSpace(p)), PointSpace(p));
80+
s = sprint(show, MIME"text/plain"(), M)
81+
@test s == "FiniteOperator : PointSpace([1.00000001]) → PointSpace([1.00000001])\n 1.00000001"
82+
p = [1+1e-8, 2+1e-8];
83+
M = Multiplication(Fun(PointSpace(p)), PointSpace(p));
84+
s = sprint(show, MIME"text/plain"(), M)
85+
@test s == ("FiniteOperator : PointSpace([1.00000001, 2.00000001]) → PointSpace([1.00000001, 2.00000001])"*
86+
"\n 1.0 ⋅ \n ⋅ 2.0")
87+
end
7788
end
7889
@testset "Iterators" begin
7990
B = ApproxFunBase.BlockInterlacer((Ones{Int}(2), Ones{Int}(2)))

0 commit comments

Comments
 (0)