Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
5 changes: 5 additions & 0 deletions test/AquaTest.jl
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions test/BugInMultiplicationTest.jl
Original file line number Diff line number Diff line change
@@ -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)
= Derivative(sp, [0,1])
Mr = Multiplication(Fun( (r, θ) -> r, sp ), sp)
rDr = Mr * Dr
testbandedblockbandedoperator(rDr)
end
8 changes: 8 additions & 0 deletions test/ChebyshevAndFourierTest.jl
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions test/ConversionTest.jl
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions test/DefiniteIntegralTest.jl
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions test/DocstringsTest.jl
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions test/ExtendingFunctionTest.jl
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions test/LaplaceInAStripTest.jl
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions test/MixFourierChebyshevTest.jl
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions test/NonlinearPowTest.jl
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions test/NullSpaceTest.jl
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions test/PeriodicXIntervalTest.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Test
using ApproxFun
using Random
using LinearAlgebra
using ApproxFunBase

@testset "periodic x interval" begin
=PeriodicSegment(-2.,2.)
dt=Interval(0,1.)
d=×dt
=Derivative(d,[1,0])
Dt=Derivative(d,[0,1])
u0=Fun->exp(-20θ^2), dθ)
ε = 0.1
u=\([Ildirichlet(dt); Dt-ε*^2-Dθ], [u0; 0.]; tolerance=1E-4)
@test (u(0.1,0.2),0.3103472600253807;atol=1E-2)
A=Dt+
ApproxFunBase.TestUtils.testbandedblockbandedoperator(A)
u=\([Ildirichlet(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
11 changes: 11 additions & 0 deletions test/PiecewiseSampleTest.jl
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions test/PiecewiseSpaceDefiniteIntegralTest.jl
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions test/SampleTest.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Test
using ApproxFun

@testset "sample" begin
f=Fun(exp)
sample(f,100000)
@time sample(f,100000)
end
13 changes: 13 additions & 0 deletions test/SamplingTest.jl
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions test/ShowTest.jl
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading