Skip to content

Commit ce78a7c

Browse files
authored
condense show space methods (#222)
* condense show space methods * remove space between order and domain
1 parent d6266d4 commit ce78a7c

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunOrthogonalPolynomials"
22
uuid = "b70543e2-c0d9-56b8-a290-0d4d6d4de211"
3-
version = "0.6.19"
3+
version = "0.6.20"
44

55
[deps]
66
ApproxFunBase = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"

src/show.jl

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,34 @@ function show(io::IO,d::Ray)
2525
end
2626

2727
## Spaces
28+
_maybetoint(x::Union{Integer, StaticInt}) = Int(x)
29+
_maybetoint(x) = x
2830

29-
function show(io::IO, S::Chebyshev)
30-
print(io, "Chebyshev(")
31-
show(io,domain(S))
32-
print(io,")")
31+
_spacename(io, ::Chebyshev) = print(io, "Chebyshev(")
32+
_spacename(io, S::Ultraspherical) = print(io,"Ultraspherical(", _maybetoint(order(S)))
33+
function _spacename(io, S::Jacobi)
34+
if S.a == S.b == 0
35+
print(io,"Legendre(")
36+
else
37+
print(io,"Jacobi(", _maybetoint(S.b), ",", _maybetoint(S.a))
38+
end
3339
end
3440

35-
function show(io::IO, S::Ultraspherical)
36-
print(io,"Ultraspherical(", order(S), ",")
37-
show(io,domain(S))
38-
print(io,")")
41+
function _maybeshowdomain(io, d)
42+
if !(d isa ChebyshevInterval)
43+
show(io, d)
44+
end
3945
end
4046

41-
function show(io::IO,S::Jacobi)
42-
S.a == S.b == 0 ? print(io,"Legendre(") : print(io,"Jacobi(", S.b, ",", S.a,",")
43-
show(io,domain(S))
47+
_showsorders(C::Chebyshev) = false
48+
_showsorders(C::Ultraspherical) = true
49+
_showsorders(C::Jacobi) = !(C.b == 0 && C.a == 0)
50+
51+
function show(io::IO, S::Union{Chebyshev, Ultraspherical, Jacobi})
52+
_spacename(io, S)
53+
!(domain(S) isa ChebyshevInterval) && _showsorders(S) && print(io, ",")
54+
_maybeshowdomain(io, domain(S))
4455
print(io,")")
4556
end
4657

47-
show(io::IO, S::Chebyshev{<:ChebyshevInterval}) = print(io, "Chebyshev()")
48-
show(io::IO, S::Ultraspherical{<:Any,<:ChebyshevInterval}) =
49-
print(io, "Ultraspherical(", order(S), ")")
50-
show(io::IO, S::Jacobi{<:ChebyshevInterval}) =
51-
S.a == S.b == 0 ? print(io,"Legendre()") : print(io,"Jacobi(", S.b, ",", S.a,")")
52-
5358
show(io::IO, S::NormalizedPolynomialSpace) = (print(io, "Normalized"); show(io, S.space))

0 commit comments

Comments
 (0)