Skip to content

Commit 6cd057a

Browse files
authored
Fix missing show method
* Fix issue #103 * Fix other test * Add interval into printing for SemiclassicalJacobi, update README * typo * bump
1 parent 0e77a04 commit 6cd057a

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SemiclassicalOrthogonalPolynomials"
22
uuid = "291c01f3-23f6-4eb6-aeb0-063a639b53f2"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.5.6"
4+
version = "0.5.7"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ This builds on top of [ClassicalOrthogonalPolynomials.jl](https://github.com/Jul
1111

1212
For example, the following gives a half-range Chebyshev polynomial:
1313
```julia
14+
julia> using SemiclassicalOrthogonalPolynomials
1415
julia> T = SemiclassicalJacobi(2, -1/2, 0, -1/2)
15-
SemiclassicalJacobi with weight x^-0.5 * (1-x)^0.0 * (2.0-x)^-0.5
16+
SemiclassicalJacobi with weight x^-0.5 * (1-x)^0.0 * (2.0-x)^-0.5 on 0..1
1617

1718
julia> T[0.1,1:10] # evaluate first 10 OPs at 0.1
1819
10-element Array{Float64,1}:
@@ -28,5 +29,5 @@ julia> T[0.1,1:10] # evaluate first 10 OPs at 0.1
2829
-1.1219700834800677
2930

3031
julia> U = SemiclassicalJacobi(2, 1/2, 0, 1/2, T) # last argument reuses computation from T
31-
SemiclassicalJacobi with weight x^0.5 * (1-x)^0.0 * (2.0-x)^0.5
32+
SemiclassicalJacobi with weight x^0.5 * (1-x)^0.0 * (2.0-x)^0.5 on 0..1
3233
```

src/SemiclassicalOrthogonalPolynomials.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using ClassicalOrthogonalPolynomials: WeightedOPLayout
33
using ClassicalOrthogonalPolynomials, FillArrays, LazyArrays, ArrayLayouts, QuasiArrays, InfiniteArrays, ContinuumArrays, LinearAlgebra, BandedMatrices,
44
SpecialFunctions, HypergeometricFunctions, InfiniteLinearAlgebra
55

6-
import Base: getindex, axes, size, \, /, *, +, -, summary, ==, copy, sum, unsafe_getindex, convert, OneTo, diff
6+
import Base: getindex, axes, size, \, /, *, +, -, summary, show, ==, copy, sum, unsafe_getindex, convert, OneTo, diff
77

88
import ArrayLayouts: MemoryLayout, ldiv, diagonaldata, subdiagonaldata, supdiagonaldata
99
import BandedMatrices: bandwidths, AbstractBandedMatrix, BandedLayout, _BandedMatrix
@@ -53,9 +53,10 @@ function sum(P::SemiclassicalJacobiWeight{T}) where T
5353
return abs(convert(T, t^c*exp(loggamma(a+1)+loggamma(b+1)-loggamma(a+b+2)) * pFq((a+1,-c),(a+b+2, ), 1/t)))
5454
end
5555

56+
show(io::IO, P::SemiclassicalJacobiWeight) = summary(io, P)
5657
function summary(io::IO, P::SemiclassicalJacobiWeight)
5758
t,a,b,c = P.t,P.a,P.b,P.c
58-
print(io, "x^$a * (1-x)^$b * ($t-x)^$c")
59+
print(io, "x^$a * (1-x)^$b * ($t-x)^$c on 0..1")
5960
end
6061

6162
function ==(A::SemiclassicalJacobiWeight, B::SemiclassicalJacobiWeight)
@@ -219,11 +220,13 @@ axes(P::SemiclassicalJacobi{T}) where T = (Inclusion(UnitInterval{T}()),OneToInf
219220

220221
orthogonalityweight(P::SemiclassicalJacobi) = SemiclassicalJacobiWeight(P.t, P.a, P.b, P.c)
221222

223+
show(io::IO, P::SemiclassicalJacobi) = summary(io, P)
222224
function summary(io::IO, P::SemiclassicalJacobi)
223225
t,a,b,c = P.t,P.a,P.b,P.c
224-
print(io, "SemiclassicalJacobi with weight x^$a * (1-x)^$b * ($t-x)^$c")
226+
print(io, "SemiclassicalJacobi with weight x^$a * (1-x)^$b * ($t-x)^$c on 0..1")
225227
end
226228

229+
227230
jacobimatrix(P::SemiclassicalJacobi) = P.X
228231

229232
"""

test/runtests.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ end
8686
W = SemiclassicalJacobi(2, 1/2, 0, -1/2, T)
8787
w_T = orthogonalityweight(T)
8888
w_W = orthogonalityweight(W)
89-
@test summary(SemiclassicalJacobiWeight(2,1,1,1)) == "x^1 * (1-x)^1 * (2-x)^1"
89+
@test summary(SemiclassicalJacobiWeight(2,1,1,1)) == "x^1 * (1-x)^1 * (2-x)^1 on 0..1"
9090
@test WeightedSemiclassicalJacobi{Float64}(2, -1/2, 0, 1/2) == SemiclassicalJacobiWeight{Float64}(2., -1/2, 0., 1/2) .* SemiclassicalJacobi{Float64}(2., -1/2, 0., 1/2)
9191

9292
@test copy(T) == T
@@ -610,5 +610,14 @@ end
610610
end
611611
end
612612

613+
@testset "Issue #103" begin
614+
w = SemiclassicalJacobiWeight(2.0, 2.3, 5.3, 0.4)
615+
P = SemiclassicalJacobi(2.0, 2.3, 5.3, 0.4)
616+
W = Weighted(P)
617+
@test sprint(show, w) == "x^2.3 * (1-x)^5.3 * (2.0-x)^0.4 on 0..1"
618+
@test sprint(show, P) == "SemiclassicalJacobi with weight x^2.3 * (1-x)^5.3 * (2.0-x)^0.4 on 0..1"
619+
@test sprint(show, W) == "Weighted(SemiclassicalJacobi with weight x^2.3 * (1-x)^5.3 * (2.0-x)^0.4 on 0..1)"
620+
end
621+
613622
include("test_derivative.jl")
614623
include("test_neg1c.jl")

0 commit comments

Comments
 (0)