diff --git a/Project.toml b/Project.toml index aa7abce30..789f3ca4c 100644 --- a/Project.toml +++ b/Project.toml @@ -41,6 +41,7 @@ FFTW = "1" FastTransforms = "0.13, 0.14, 0.15, 0.16, 0.17" IntervalSets = "0.7.5" LinearAlgebra = "1" +ParallelTestRunner = "2" Random = "1" RecipesBase = "1.0" Reexport = "1.0" @@ -57,8 +58,9 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" DualNumbers = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74" FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" +ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Aqua", "BandedMatrices", "BlockBandedMatrices", "Documenter", "DualNumbers", "FFTW", "Random", "Test"] +test = ["Aqua", "BandedMatrices", "BlockBandedMatrices", "Documenter", "DualNumbers", "FFTW", "ParallelTestRunner", "Random", "Test"] diff --git a/test/AquaTest.jl b/test/AquaTest.jl new file mode 100644 index 000000000..adfb2797d --- /dev/null +++ b/test/AquaTest.jl @@ -0,0 +1,5 @@ +using Aqua +@testset "Project quality" begin + Aqua.test_all(ApproxFun, ambiguities=false, undefined_exports=false, + stale_deps=(; ignore=[:ApproxFunBaseTest]), piracies = false) +end diff --git a/test/BugInMultiplicationTest.jl b/test/BugInMultiplicationTest.jl new file mode 100644 index 000000000..5d134f911 --- /dev/null +++ b/test/BugInMultiplicationTest.jl @@ -0,0 +1,19 @@ +using Test +using ApproxFun +using ApproxFunBase + +@testset "Bug in Multiplication" begin + dom = Interval(0.001, 1) × PeriodicSegment(-pi, pi) + @test blocklengths(Space(dom)) == 2:2:∞ + r,r2 = Fun((r,t) -> [r;r^2], dom) + @test r(0.1,0.2) ≈ 0.1 + @test r2(0.1,0.2) ≈ 0.1^2 + sp = Space(dom) + Dr = Derivative(sp, [1,0]) + @test blockbandwidths(Dr) == (-1,1) + @test subblockbandwidths(Dr) == (1,3) + Dθ = Derivative(sp, [0,1]) + Mr = Multiplication(Fun( (r, θ) -> r, sp ), sp) + rDr = Mr * Dr + testbandedblockbandedoperator(rDr) +end diff --git a/test/ChebyshevAndFourierTest.jl b/test/ChebyshevAndFourierTest.jl new file mode 100644 index 000000000..b73665e91 --- /dev/null +++ b/test/ChebyshevAndFourierTest.jl @@ -0,0 +1,8 @@ +using Test +using ApproxFun + +@testset "Chebyshev and Fourier" begin + @test norm(Fun(x->Fun(cos,Fourier(-π .. π),20)(x),20)-Fun(cos,20)) <100eps() + @test norm(Fun(x->Fun(cos,Fourier(-π .. π))(x))-Fun(cos)) <100eps() + @test norm(Fun(x->Fun(cos,Laurent)(x))-Fun(cos)) <100eps() +end diff --git a/test/ConversionTest.jl b/test/ConversionTest.jl new file mode 100644 index 000000000..2fd69ba00 --- /dev/null +++ b/test/ConversionTest.jl @@ -0,0 +1,8 @@ +using Test +using ApproxFun + +@testset "Conversion" begin + f=Fun(t->[cos(t) 0;sin(t) 1],-π..π) + g=Fun(f,Space(PeriodicSegment(-π,π))) + @test g(.1) ≈ f(.1) +end diff --git a/test/DefiniteIntegralTest.jl b/test/DefiniteIntegralTest.jl new file mode 100644 index 000000000..b20a2a9dd --- /dev/null +++ b/test/DefiniteIntegralTest.jl @@ -0,0 +1,9 @@ +using Test +using ApproxFun + +@testset "definite integral" begin + Σ = DefiniteIntegral() + f1 = Fun(t->cos(cos(t)),-π..π) + f = Fun(t->cos(cos(t)),Laurent(-π..π)) + @test sum(f1) ≈ Σ*f +end diff --git a/test/DocstringsTest.jl b/test/DocstringsTest.jl new file mode 100644 index 000000000..55dc212d1 --- /dev/null +++ b/test/DocstringsTest.jl @@ -0,0 +1,8 @@ +using Documenter +DocMeta.setdocmeta!(ApproxFunBase, :DocTestSetup, :(using ApproxFun); recursive=true) +DocMeta.setdocmeta!(ApproxFun, :DocTestSetup, :(using ApproxFun); recursive=true) + +@testset "doctests" begin + doctest(ApproxFun) + doctest(ApproxFunBase, manual=false) +end diff --git a/test/ExtendingFunctionTest.jl b/test/ExtendingFunctionTest.jl new file mode 100644 index 000000000..4a4714c4d --- /dev/null +++ b/test/ExtendingFunctionTest.jl @@ -0,0 +1,9 @@ +using Test +using ApproxFun + +@testset "Extending function" begin + Γ = Segment(-im,1.0-im) ∪ Curve(Fun(x->exp(0.8im)*(x+x^2-1+im*(x-4x^3+x^4)/6))) ∪ Circle(2.0,0.2) + @test isempty(component(Γ,1)\component(Γ,1)) + @test Γ \ component(Γ,1) == component(Γ,2) ∪ component(Γ,3) + @test norm(Fun(ones(component(Γ,1)),Γ) - Fun(x->x ∈ component(Γ,1) ? 1.0 : 0.0,Γ)) == 0 +end diff --git a/test/LaplaceInAStripTest.jl b/test/LaplaceInAStripTest.jl new file mode 100644 index 000000000..1609b6344 --- /dev/null +++ b/test/LaplaceInAStripTest.jl @@ -0,0 +1,17 @@ +using Test +using ApproxFun + +@testset "Laplace in a strip" begin + d = PeriodicSegment() × ChebyshevInterval() + g=Fun((x,y)->real(cos(x+im*y)),∂(d)) + @test g(0.1,1.0) ≈ real(cos(0.1+im)) + @test g(0.1,-1.0) ≈ real(cos(0.1-im)) + v=[g;0] + @test v(0.1,-1) ≈ [real(cos(0.1-im));0] + A=[Dirichlet(d);Laplacian(d)] + a = space(v) + b = rangespace(A) + @test Fun(component(v[1],1), component(b[1],1))(0.1,-1.0) ≈ v(0.1,-1.0)[1] + @test Fun(component(v[1],2), component(b[1],2))(0.1,1.0) ≈ v(0.1,1.0)[1] + @test ApproxFun.default_Fun(v[1] , b[1])(0.1,1.0) ≈ v(0.1,1.0)[1] +end diff --git a/test/MixFourierChebyshevTest.jl b/test/MixFourierChebyshevTest.jl new file mode 100644 index 000000000..97b5e8475 --- /dev/null +++ b/test/MixFourierChebyshevTest.jl @@ -0,0 +1,17 @@ +using Test +using ApproxFun + +@testset "Mix Fourier-Chebyshev (#602)" begin + s = Chebyshev(-π..π) + a = Fun(t-> 1+sin(cos(2t)), s) + L = Derivative() + a + f = Fun(t->exp(sin(10t)), s) + B = periodic(s,0) + @time uChebyshev = [B;L] \ [0.;f] + s = Fourier(-π..π) + a = Fun(t-> 1+sin(cos(2t)), s) + L = Derivative() + a + f = Fun(t->exp(sin(10t)), s) + @time uFourier = L\f + @test norm(uFourier-uChebyshev) ≤ 100eps() +end diff --git a/test/NonlinearPowTest.jl b/test/NonlinearPowTest.jl new file mode 100644 index 000000000..b4d56d358 --- /dev/null +++ b/test/NonlinearPowTest.jl @@ -0,0 +1,16 @@ +using Test +using ApproxFun + +@testset "nonlinear pow" begin + x = Fun(identity, 0..10) + n = 2 + u₀ = 0.0x # initial guess + N = u -> [u'(0), u(0)-1, x*u'' + 2*u' + x*u^n] + u = newton(N, u₀) # perform Newton iteration in function space + @test u(0.1) ≈ 0.9983349985461484 + n = 4.5 + u₀ = 0.0x+1 # initial guess + N = u -> [u'(0), u(0)-1, x*u'' + 2*u' + x*u^n] + u = newton(N, u₀) # perform Newton iteration in function space + @test u(0.1) ≈ 0.9983370741307388 +end diff --git a/test/NullSpaceTest.jl b/test/NullSpaceTest.jl new file mode 100644 index 000000000..d890c2ad4 --- /dev/null +++ b/test/NullSpaceTest.jl @@ -0,0 +1,19 @@ +using Test +using ApproxFun + +@testset "Null space" begin + d=ChebyshevInterval() + D=Derivative(d) + A=D^2-I + @time κ=nullspace(A) + @test length(κ) == 2 + c=[κ(0.);κ'(0.)]\[exp(0.),exp(0.)] + u=(κ*c)[1] + @test u(1.0) ≈ ℯ + d=(-50..5.) + x=Fun(identity,d) + D=Derivative(d) + @time u=nullspace(D^2-x) + c=[u(leftendpoint(d)); u(rightendpoint(d))]\[airyai.(endpoints(d))...] + @test norm((u*c)[1]-Fun(airyai,d))<10000eps() +end diff --git a/test/PeriodicXIntervalTest.jl b/test/PeriodicXIntervalTest.jl new file mode 100644 index 000000000..540b48373 --- /dev/null +++ b/test/PeriodicXIntervalTest.jl @@ -0,0 +1,32 @@ +using Test +using ApproxFun +using Random +using LinearAlgebra +using ApproxFunBase + +@testset "periodic x interval" begin + dθ=PeriodicSegment(-2.,2.) + dt=Interval(0,1.) + d=dθ×dt + Dθ=Derivative(d,[1,0]) + Dt=Derivative(d,[0,1]) + u0=Fun(θ->exp(-20θ^2), dθ) + ε = 0.1 + u=\([I⊗ldirichlet(dt); Dt-ε*Dθ^2-Dθ], [u0; 0.]; tolerance=1E-4) + @test ≈(u(0.1,0.2),0.3103472600253807;atol=1E-2) + A=Dt+Dθ + ApproxFunBase.TestUtils.testbandedblockbandedoperator(A) + u=\([I⊗ldirichlet(dt); Dt+Dθ], [u0; 0.0]; tolerance=1E-6) + @test ≈(u(0.2,0.1),u0(0.1);atol=1E-6) + + d=PeriodicSegment() × ChebyshevInterval() + u_ex=Fun((x,y)->real(cos(x+im*y)),d) + @test u_ex(1.0,0.1) ≈ real(cos(1.0+im*0.1)) atol=10eps() + B=Dirichlet(Space(d)) + @test B.order == 0 + g=Fun((x,y)->real(cos(x+im*y)),rangespace(B)) + @test norm((B*u_ex-g).coefficients) < 100eps() + testbandedblockbandedoperator(Laplacian(d)) + @time u=[B;Laplacian(d)]\[g;0.] + @test u(.1,.2) ≈ real(cos(.1+.2im)) +end diff --git a/test/PiecewiseSampleTest.jl b/test/PiecewiseSampleTest.jl new file mode 100644 index 000000000..6d6012d2a --- /dev/null +++ b/test/PiecewiseSampleTest.jl @@ -0,0 +1,11 @@ +using Test +using ApproxFun + +@testset "piecewise sample (#635)" begin + f = abs(Fun(sin, -5..5)) + @test integrate(f)(-4.0) ≈ -(cos(-4.0) - cos(-5.0)) + @test -(cos(-π) - cos(-5.0)) + cos(-3.0) - cos(-π) ≈ integrate(f)(-3.0) + r = ApproxFun.sample(f,10) + @test maximum(r) ≤ 5 + @test minimum(r) ≥ -5 +end diff --git a/test/PiecewiseSpaceDefiniteIntegralTest.jl b/test/PiecewiseSpaceDefiniteIntegralTest.jl new file mode 100644 index 000000000..db973a99e --- /dev/null +++ b/test/PiecewiseSpaceDefiniteIntegralTest.jl @@ -0,0 +1,13 @@ +using Test +using ApproxFun +using Random + +@testset "Piecewise space definite integral" begin + Γ=Segment(-im,1.0-im) ∪ Curve(Fun(x->exp(0.8im)*(x+x^2-1+im*(x-4x^3+x^4)/6))) ∪ Circle(2.0,0.2) + z=Fun(Γ) + S=PiecewiseSpace(map(d->isa(d,Circle) ? Fourier(d) : JacobiWeight(0.5,0.5,Ultraspherical(1,d)),components(Γ))) + B=DefiniteLineIntegral(S) + Random.seed!(0) + f=Fun(S,rand(20)) + @test B*f ≈ linesum(component(f,1)) + linesum(component(f,2)) + linesum(component(f,3)) +end diff --git a/test/SampleTest.jl b/test/SampleTest.jl new file mode 100644 index 000000000..2b3009c80 --- /dev/null +++ b/test/SampleTest.jl @@ -0,0 +1,8 @@ +using Test +using ApproxFun + +@testset "sample" begin + f=Fun(exp) + sample(f,100000) + @time sample(f,100000) +end diff --git a/test/SamplingTest.jl b/test/SamplingTest.jl new file mode 100644 index 000000000..67b64cfb9 --- /dev/null +++ b/test/SamplingTest.jl @@ -0,0 +1,13 @@ +using Test +using ApproxFun + +@testset "Sampling" begin + ff=(x,y)->(x-y)^2*exp(-x^2/2-y^2/2) + f=Fun(ff,Domain(-4..4)^2) + r=ApproxFun.sample(f,5000) + g=sum(f,1)/sum(f) + @test g(0.1) ≈ 0.2004758624973169 + f = Fun(x -> exp(-x^2/2),-5..5) + g = cumsum(f) + @test g(ApproxFun.bisectioninv(g,0.5)) ≈ 0.5 +end diff --git a/test/ShowTest.jl b/test/ShowTest.jl new file mode 100644 index 000000000..d1fa98a4a --- /dev/null +++ b/test/ShowTest.jl @@ -0,0 +1,21 @@ +using Test +using ApproxFun + +@testset "show" begin + op = Derivative(Chebyshev()) + io = IOBuffer() + @test summary(io, op) isa Nothing + @test contains(String(take!(io)), " : $(domainspace(op)) → $(rangespace(op))") + show(io, op) + @test contains(String(take!(io)), " : $(domainspace(op)) → $(rangespace(op))") + @test summary(io, ApproxFun.ArraySpace(Chebyshev(), 2)) isa Nothing + @test contains(String(take!(io)), "ArraySpace") + Q = QuotientSpace(Dirichlet(Chebyshev())) + @test startswith(repr(Q), "Chebyshev() /") + show(io, MIME"text/plain"(), Q) + s = String(take!(io)) + @test startswith(s, "Chebyshev() /") + f = Fun(Chebyshev()^2, [1,3,4]) + @test contains(repr(f), repr(space(f))) + @test contains(repr(f), repr(coefficients(f))) +end diff --git a/test/runtests.jl b/test/runtests.jl index 99608d5cc..5dfa301a7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,264 +1,32 @@ module ApproxFun_Runtests using ApproxFun -using Random -using Test -using LinearAlgebra -using SpecialFunctions -using ApproxFunBase -using ApproxFunBase: blocklengths, ∞, blockbandwidths, subblockbandwidths -using ApproxFunBase.TestUtils: testbandedblockbandedoperator +using ParallelTestRunner -using Aqua -@testset "Project quality" begin - Aqua.test_all(ApproxFun, ambiguities=false, undefined_exports=false, - stale_deps=(; ignore=[:ApproxFunBaseTest]), piracies = false) -end - -using Documenter -DocMeta.setdocmeta!(ApproxFunBase, :DocTestSetup, :(using ApproxFun); recursive=true) -DocMeta.setdocmeta!(ApproxFun, :DocTestSetup, :(using ApproxFun); recursive=true) - -@testset "doctests" begin - doctest(ApproxFun) - doctest(ApproxFunBase, manual=false) -end - -include(joinpath(@__DIR__, "testutils.jl")) - -include("ReadmeTest.jl"); GC.gc(); -include("ExtrasTest.jl"); GC.gc(); -include("NumberTypeTest.jl"); GC.gc(); - -@testset "Chebyshev and Fourier" begin - @test norm(Fun(x->Fun(cos,Fourier(-π .. π),20)(x),20)-Fun(cos,20)) <100eps() - @test norm(Fun(x->Fun(cos,Fourier(-π .. π))(x))-Fun(cos)) <100eps() - @test norm(Fun(x->Fun(cos,Laurent)(x))-Fun(cos)) <100eps() -end - - -@testset "Piecewise space definite integral" begin - Γ=Segment(-im,1.0-im) ∪ Curve(Fun(x->exp(0.8im)*(x+x^2-1+im*(x-4x^3+x^4)/6))) ∪ Circle(2.0,0.2) - z=Fun(Γ) - - S=PiecewiseSpace(map(d->isa(d,Circle) ? Fourier(d) : JacobiWeight(0.5,0.5,Ultraspherical(1,d)),components(Γ))) - - - B=DefiniteLineIntegral(S) - - Random.seed!(0) - f=Fun(S,rand(20)) - @test B*f ≈ linesum(component(f,1)) + linesum(component(f,2)) + linesum(component(f,3)) -end - -@testset "Extending function" begin - Γ = Segment(-im,1.0-im) ∪ Curve(Fun(x->exp(0.8im)*(x+x^2-1+im*(x-4x^3+x^4)/6))) ∪ Circle(2.0,0.2) - - @test isempty(component(Γ,1)\component(Γ,1)) - @test Γ \ component(Γ,1) == component(Γ,2) ∪ component(Γ,3) - - @test norm(Fun(ones(component(Γ,1)),Γ) - Fun(x->x ∈ component(Γ,1) ? 1.0 : 0.0,Γ)) == 0 -end +# Start with autodiscovered tests +testsuite = find_tests(pwd()) -@testset "periodic x interval" begin - dθ=PeriodicSegment(-2.,2.);dt=Interval(0,1.) - d=dθ×dt - Dθ=Derivative(d,[1,0]);Dt=Derivative(d,[0,1]) - u0=Fun(θ->exp(-20θ^2),dθ) +# Parse arguments +args = parse_args(ARGS) - ε = 0.1 - @time u=\([I⊗ldirichlet(dt);Dt-ε*Dθ^2-Dθ],[u0;0.];tolerance=1E-4) - @test ≈(u(0.1,0.2),0.3103472600253807;atol=1E-2) - - A=Dt+Dθ - testbandedblockbandedoperator(A) - - @time u=\([I⊗ldirichlet(dt);Dt+Dθ],[u0;0.0];tolerance=1E-6) - @test ≈(u(0.2,0.1),u0(0.1);atol=1E-6) +if filter_tests!(testsuite, args) + # Remove tests that shouldn't run on Windows + delete!(testsuite, "testutils") end +const init_code = quote + using ApproxFun + using Random + using Test + using LinearAlgebra + using SpecialFunctions + using ApproxFunBase + using ApproxFunBase: blocklengths, ∞, blockbandwidths, subblockbandwidths + using ApproxFunBase.TestUtils: testbandedblockbandedoperator -@testset "Laplace in a strip" begin - d = PeriodicSegment() × ChebyshevInterval() - g=Fun((x,y)->real(cos(x+im*y)),∂(d)) # boundary data - - - @test g(0.1,1.0) ≈ real(cos(0.1+im)) - @test g(0.1,-1.0) ≈ real(cos(0.1-im)) - v=[g;0] - @test v(0.1,-1) ≈ [real(cos(0.1-im));0] - - A=[Dirichlet(d);Laplacian(d)] - a = space(v) - b = rangespace(A) - - @test Fun(component(v[1],1), component(b[1],1))(0.1,-1.0) ≈ v(0.1,-1.0)[1] - @test Fun(component(v[1],2), component(b[1],2))(0.1,1.0) ≈ v(0.1,1.0)[1] - @test ApproxFun.default_Fun(v[1] , b[1])(0.1,1.0) ≈ v(0.1,1.0)[1] + include(joinpath(@__DIR__, "testutils.jl")) end -@testset "Bug in Multiplication" begin - dom = Interval(0.001, 1) × PeriodicSegment(-pi, pi) - - @test blocklengths(Space(dom)) == 2:2:∞ - - r,r2 = Fun((r,t) -> [r;r^2], dom) - - @test r(0.1,0.2) ≈ 0.1 - @test r2(0.1,0.2) ≈ 0.1^2 - - sp = Space(dom) - Dr = Derivative(sp, [1,0]) - @test blockbandwidths(Dr) == (-1,1) - @test subblockbandwidths(Dr) == (1,3) - - Dθ = Derivative(sp, [0,1]) - Mr = Multiplication(Fun( (r, θ) -> r, sp ), sp) - rDr = Mr * Dr - - testbandedblockbandedoperator(rDr) -end - -@testset "Periodic x Interval" begin - d=PeriodicSegment() × ChebyshevInterval() - - u_ex=Fun((x,y)->real(cos(x+im*y)),d) - @test u_ex(1.0,0.1) ≈ real(cos(1.0+im*0.1)) atol=10eps() - - B=Dirichlet(Space(d)) - - @test B.order == 0 # tests stupid bug - g=Fun((x,y)->real(cos(x+im*y)),rangespace(B)) # boundary data - - @test norm((B*u_ex-g).coefficients) < 100eps() - - testbandedblockbandedoperator(Laplacian(d)) - - @time u=[B;Laplacian(d)]\[g;0.] - - @test u(.1,.2) ≈ real(cos(.1+.2im)) -end - -@testset "Mix Fourier-Chebyshev (#602)" begin - s = Chebyshev(-π..π) - a = Fun(t-> 1+sin(cos(2t)), s) - L = Derivative() + a - f = Fun(t->exp(sin(10t)), s) - B = periodic(s,0) - @time uChebyshev = [B;L] \ [0.;f] - - s = Fourier(-π..π) - a = Fun(t-> 1+sin(cos(2t)), s) - L = Derivative() + a - f = Fun(t->exp(sin(10t)), s) - @time uFourier = L\f - - @test norm(uFourier-uChebyshev) ≤ 100eps() -end - -@testset "Conversion" begin - f=Fun(t->[cos(t) 0;sin(t) 1],-π..π) - g=Fun(f,Space(PeriodicSegment(-π,π))) - @test g(.1) ≈ f(.1) -end - -@testset "definite integral" begin - Σ = DefiniteIntegral() - - f1 = Fun(t->cos(cos(t)),-π..π) - f = Fun(t->cos(cos(t)),Laurent(-π..π)) - - @test sum(f1) ≈ Σ*f -end - - -@testset "Sampling" begin - ff=(x,y)->(x-y)^2*exp(-x^2/2-y^2/2) - - f=Fun(ff,Domain(-4..4)^2) - r=ApproxFun.sample(f,5000) - - - #We can compare the histogram to the 1-point correlation - g=sum(f,1)/sum(f) - @test g(0.1) ≈ 0.2004758624973169 - - # check bisection inv - f = Fun(x -> exp(-x^2/2),-5..5) - g = cumsum(f) - @test g(ApproxFun.bisectioninv(g,0.5)) ≈ 0.5 -end - -@testset "piecewise sample (#635)" begin - f = abs(Fun(sin, -5..5)) - @test integrate(f)(-4.0) ≈ -(cos(-4.0) - cos(-5.0)) - @test -(cos(-π) - cos(-5.0)) + cos(-3.0) - cos(-π) ≈ integrate(f)(-3.0) - r = ApproxFun.sample(f,10) - @test maximum(r) ≤ 5 - @test minimum(r) ≥ -5 -end - -@testset "sample" begin - f=Fun(exp) - sample(f,100000) - @time sample(f,100000) -end - -@testset "Null space" begin - d=ChebyshevInterval() - D=Derivative(d) - A=D^2-I - @time κ=nullspace(A) - @test length(κ) == 2 - - c=[κ(0.);κ'(0.)]\[exp(0.),exp(0.)] - u=(κ*c)[1] - - @test u(1.0) ≈ ℯ - - d=(-50..5.) - x=Fun(identity,d) - D=Derivative(d) - @time u=nullspace(D^2-x) - c=[u(leftendpoint(d)); u(rightendpoint(d))]\[airyai.(endpoints(d))...] - @test norm((u*c)[1]-Fun(airyai,d))<10000eps() -end - -@testset "nonlinear pow" begin - x = Fun(identity, 0..10) - n = 2 - u₀ = 0.0x # initial guess - N = u -> [u'(0), u(0)-1, x*u'' + 2*u' + x*u^n] - u = newton(N, u₀) # perform Newton iteration in function space - @test u(0.1) ≈ 0.9983349985461484 - - n = 4.5 - u₀ = 0.0x+1 # initial guess - N = u -> [u'(0), u(0)-1, x*u'' + 2*u' + x*u^n] - u = newton(N, u₀) # perform Newton iteration in function space - @test u(0.1) ≈ 0.9983370741307388 -end - -@testset "show" begin - op = Derivative(Chebyshev()) - io = IOBuffer() - @test summary(io, op) isa Nothing - @test contains(String(take!(io)), " : $(domainspace(op)) → $(rangespace(op))") - show(io, op) - @test contains(String(take!(io)), " : $(domainspace(op)) → $(rangespace(op))") - - @test summary(io, ApproxFun.ArraySpace(Chebyshev(), 2)) isa Nothing - @test contains(String(take!(io)), "ArraySpace") - - Q = QuotientSpace(Dirichlet(Chebyshev())) - @test startswith(repr(Q), "Chebyshev() /") - show(io, MIME"text/plain"(), Q) - s = String(take!(io)) - @test startswith(s, "Chebyshev() /") - - f = Fun(Chebyshev()^2, [1,3,4]) - @test contains(repr(f), repr(space(f))) - @test contains(repr(f), repr(coefficients(f))) -end +runtests(ApproxFun, args; testsuite, init_code) end # module