Skip to content

Commit 2fffa7d

Browse files
authored
move show methods to ApproxFunBase (#784)
1 parent d3337d3 commit 2fffa7d

File tree

3 files changed

+5
-171
lines changed

3 files changed

+5
-171
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
2020

2121
[compat]
2222
AbstractFFTs = "1.0"
23-
ApproxFunBase = "0.5"
23+
ApproxFunBase = "0.6"
2424
ApproxFunFourier = "0.2"
2525
ApproxFunOrthogonalPolynomials = "0.4"
2626
ApproxFunSingularities = "0.2"

src/Extras/show.jl

Lines changed: 0 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
## Domains
22

3-
show(io::IO,d::Segment) = print(io,"the segment [$(leftendpoint(d)),$(rightendpoint(d))]")
43
function show(io::IO,d::Line)
54
if d.center == angle(d) == 0 && d.α == d.β == -1.
65
print(io,"")
@@ -37,14 +36,6 @@ show(io::IO,d::Point) = print(io,"Point($(d.x))")
3736

3837
## Spaces
3938

40-
show(io::IO,::ConstantSpace{AnyDomain}) = print(io,"ConstantSpace")
41-
show(io::IO,S::ConstantSpace) = print(io,"ConstantSpace($(domain(S)))")
42-
show(io::IO,f::Fun{ConstantSpace{AnyDomain}}) =
43-
print(io,"$(convert(Number,f)) anywhere")
44-
45-
show(io::IO,f::Fun{ConstantSpace{DD,RR}}) where {DD,RR} =
46-
print(io,"$(convert(Number,f)) on $(domain(f))")
47-
4839
for typ in ("Chebyshev","Fourier","Laurent","Taylor","SinSpace","CosSpace")
4940
TYP = Meta.parse(typ)
5041
@eval function show(io::IO,S::$TYP{D,R}) where {D,R}
@@ -105,164 +96,3 @@ function show(io::IO,s::LogWeight)
10596
show(io,s.space)
10697
print(io,"]")
10798
end
108-
109-
function show(io::IO,s::QuotientSpace)
110-
show(io,s.space)
111-
print(io," /\n")
112-
show(io,s.bcs)
113-
end
114-
115-
function show(io::IO, m::MIME"text/plain", s::QuotientSpace)
116-
show(io,s.space)
117-
print(io," /\n")
118-
show(io, m, s.bcs, header = false)
119-
end
120-
121-
122-
function show(io::IO,ss::SumSpace)
123-
s = components(ss)
124-
show(io,s[1])
125-
for sp in s[2:end]
126-
print(io,"")
127-
show(io,sp)
128-
end
129-
end
130-
131-
132-
function show(io::IO,ss::PiecewiseSpace)
133-
s = components(ss)
134-
show(io,s[1])
135-
for sp in s[2:end]
136-
print(io,"")
137-
show(io,sp)
138-
end
139-
end
140-
141-
summarystr(ss::ArraySpace) = string(Base.dims2string(length.(axes(ss))), " ArraySpace")
142-
summary(io::IO, ss::ArraySpace) = print(io, summarystr(ss))
143-
function show(io::IO,ss::ArraySpace;header::Bool=true)
144-
header && print(io,summarystr(ss)*":\n")
145-
show(io, ss.spaces)
146-
end
147-
148-
function show(io::IO,s::TensorSpace)
149-
d = length(s.spaces)
150-
for i=1:d-1
151-
show(io,s.spaces[i])
152-
print(io,"")
153-
end
154-
show(io,s.spaces[d])
155-
end
156-
157-
function show(io::IO,s::SubSpace)
158-
print(io,s.space)
159-
print(io,"|")
160-
show(io,s.indexes)
161-
end
162-
163-
164-
## Fun
165-
166-
show(io::IO, ::MIME"text/plain", f::Fun) = show(io, f)
167-
168-
function show(io::IO, f::Fun)
169-
print(io,"Fun(")
170-
show(io,f.space)
171-
print(io,",")
172-
show(io,f.coefficients)
173-
print(io,")")
174-
end
175-
176-
## MultivariateFun
177-
178-
show(io::IO, ::MIME"text/plain", f::MultivariateFun) = show(io, f)
179-
180-
function show(io::IO,L::LowRankFun)
181-
print(io,"LowRankFun on ",space(L)," of rank ",rank(L),".")
182-
end
183-
184-
function show(io::IO,P::ProductFun)
185-
print(io,"ProductFun on ",space(P),".")
186-
end
187-
188-
189-
190-
## Operator
191-
192-
summarystr(B::Operator) = string(typeof(B).name.name, " : ", domainspace(B), "", rangespace(B))
193-
summary(io::IO, B::Operator) = print(io, summarystr(B))
194-
195-
struct PrintShow
196-
str
197-
end
198-
Base.show(io::IO,N::PrintShow) = print(io,N.str)
199-
200-
show(io::IO, B::Operator; kw...) = summary(io, B)
201-
202-
function show(io::IO, ::MIME"text/plain", B::Operator;header::Bool=true)
203-
header && println(io, summarystr(B))
204-
dsp=domainspace(B)
205-
206-
if !isambiguous(domainspace(B)) && (eltype(B) <: Number)
207-
if isbanded(B) && isinf(size(B,1)) && isinf(size(B,2))
208-
BM=B[1:10,1:10]
209-
210-
M=Matrix{Any}(undef,11,11)
211-
fill!(M,PrintShow(""))
212-
for j = 1:size(BM,2),k = colrange(BM,j)
213-
M[k,j]=BM[k,j]
214-
end
215-
216-
for k=max(1,11-bandwidth(B,2)):11
217-
M[k,end]=PrintShow("")
218-
end
219-
for j=max(1,11-bandwidth(B,1)):10
220-
M[end,j]=PrintShow("")
221-
end
222-
223-
print_array(io, M)
224-
elseif isinf(size(B,1)) && isinf(size(B,2))
225-
BM=B[1:10,1:10]
226-
227-
M=Matrix{Any}(undef,11,11)
228-
for k=1:10,j=1:10
229-
M[k,j]=BM[k,j]
230-
end
231-
232-
M[1,end]=PrintShow("")
233-
M[end,1]=PrintShow("")
234-
235-
for k=2:11
236-
M[k,end]=M[end,k]=PrintShow("")
237-
end
238-
239-
print_array(io, M)
240-
elseif isinf(size(B,1))
241-
BM=B[1:10,1:size(B,2)]
242-
243-
M=Matrix{Any}(undef,11,size(B,2))
244-
for k=1:10,j=1:size(B,2)
245-
M[k,j]=BM[k,j]
246-
end
247-
for k=1:size(B,2)
248-
M[end,k]=PrintShow("")
249-
end
250-
251-
print_array(io, M)
252-
elseif isinf(size(B,2))
253-
BM=B[1:size(B,1),1:10]
254-
255-
M=Matrix{Any}(undef,size(B,1),11)
256-
for k=1:size(B,1),j=1:10
257-
M[k,j]=BM[k,j]
258-
end
259-
for k=1:size(B,1)
260-
M[k,end]=PrintShow("")
261-
end
262-
263-
print_array(io, M)
264-
else
265-
print_array(io, AbstractMatrix(B)[1:size(B,1),1:size(B,2)])
266-
end
267-
end
268-
end

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,8 @@ end
240240
show(io, MIME"text/plain"(), Q)
241241
s = String(take!(io))
242242
@test startswith(s, "Chebyshev() /")
243+
244+
f = Fun(Chebyshev()^2, [1,3,4])
245+
@test contains(repr(f), repr(space(f)))
246+
@test contains(repr(f), repr(coefficients(f)))
243247
end

0 commit comments

Comments
 (0)