Skip to content

Commit c6f4c50

Browse files
authored
Fix show for Fun in an ArraySpace (#556)
* Fix show for Fun in an ArraySpace * round-trippable show for ArraySpace * test for ArraySpace show
1 parent 4e35ff9 commit c6f4c50

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/show.jl

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@ function show(io::IO, f::Fun)
1010
print(io,")")
1111
end
1212

13-
evalconst(f, ::AnyDomain) = f(0.0)
14-
evalconst(f, d) = f(leftendpoint(d))
15-
evalconst(f, d::Union{Point, UnionDomain{<:Any, <:Tuple{Point, Vararg{Point}}}}) = f(d)
16-
17-
function show(io::IO,f::Fun{<:Union{ConstantSpace, ArraySpace{<:ConstantSpace}}})
18-
d = domain(f)
19-
print(io, evalconst(f, domain(f)))
20-
print(io, d isa AnyDomain ? " anywhere" : " on " * string(d))
21-
end
22-
2313
## MultivariateFun
2414

2515
show(io::IO, ::MIME"text/plain", f::MultivariateFun) = show(io, f)
@@ -159,9 +149,8 @@ end
159149

160150
summarystr(ss::ArraySpace) = string(Base.dims2string(length.(axes(ss))), " ArraySpace")
161151
summary(io::IO, ss::ArraySpace) = print(io, summarystr(ss))
162-
function show(io::IO,ss::ArraySpace;header::Bool=true)
163-
header && print(io,summarystr(ss)*":\n")
164-
show(io, ss.spaces)
152+
function show(io::IO, ss::ArraySpace; header::Bool=true)
153+
print(io, ArraySpace, "(", ss.spaces, ")")
165154
end
166155

167156
function show(io::IO,s::TensorSpace)

test/show.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
@test startswith(rpr, "PiecewiseSpace")
4343
@test contains(rpr, repr(p))
4444
end
45+
@testset "ArraySpace" begin
46+
spaces = [PointSpace(1:1), PointSpace(2:2)]
47+
A = ApproxFunBase.ArraySpace(spaces)
48+
@test startswith(repr(A), "$(ApproxFunBase.ArraySpace)")
49+
@test contains(repr(A), repr(spaces))
50+
end
4551
end
4652
@testset "Fun" begin
4753
f = Fun(PointSpace(1:3), [1,2,3])

0 commit comments

Comments
 (0)