Skip to content

Commit d95695e

Browse files
authored
Ultraspherical conversion error catching (#32)
* Ultraspherical conversion error catching Closes #31 * Ultraspherical conversion fix error catch * Add tests for Ultraspherical conversion argument error
1 parent 3231b76 commit d95695e

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/Spaces/Ultraspherical/UltrasphericalOperators.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ function Conversion(A::Ultraspherical,B::Ultraspherical)
141141
a=order(A); b=order(B)
142142
if b==a
143143
ConversionWrapper(Operator(I,A))
144-
elseif a<ba+1 || b<ab+1
144+
elseif -1 b-a 1 && (a,b) (2,1)
145145
ConcreteConversion(A,B)
146-
elseif b 1
146+
elseif b-a > 1
147147
d=domain(A)
148148
ConversionWrapper(TimesOperator(Conversion(Ultraspherical(b-1,d),B),
149149
Conversion(A,Ultraspherical(b-1,d))))
150150
else
151-
error("Cannot convert from $A to $B")
151+
throw(ArgumentError("Cannot convert from $A to $B"))
152152
end
153153
end
154154

test/UltrasphericalTest.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using ApproxFunOrthogonalPolynomials, ApproxFunBase, Test, SpecialFunctions, LinearAlgebra
2+
import ApproxFunBase: testbandedbelowoperator, testbandedoperator, testspace, testtransforms, Vec,
3+
maxspace, NoSpace, hasconversion, testfunctional,
4+
reverseorientation, ReverseOrientation
5+
import ApproxFunOrthogonalPolynomials: jacobip
6+
7+
@testset "Ultraspherical" begin
8+
@testset "Conversion" begin
9+
# Tests whether invalid/unimplemented arguments correctly throws ArgumentError
10+
@test_throws ArgumentError Conversion(Ultraspherical(2), Ultraspherical(1))
11+
@test_throws ArgumentError Conversion(Ultraspherical(3), Ultraspherical(1.9))
12+
end
13+
end

0 commit comments

Comments
 (0)