From 48da2f30fe531e3c06fab76030f165c2c5d24f10 Mon Sep 17 00:00:00 2001 From: fgasdia Date: Sat, 19 Dec 2020 15:12:47 -0700 Subject: [PATCH] Make tests Julia 1.0 compatible --- src/Romberg.jl | 2 +- test/runtests.jl | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Romberg.jl b/src/Romberg.jl index 86290b8..221231d 100644 --- a/src/Romberg.jl +++ b/src/Romberg.jl @@ -78,7 +78,7 @@ is a prime number, it is nearly equivalent to the trapezoidal rule without extra # Examples ```jldoctest -julia> x = range(0, π, length=2^8+1); +julia> x = range(0, stop=π, length=2^8+1); julia> romberg(x, sin.(x)) (2.0000000000000018, 1.9984014443252818e-15) diff --git a/test/runtests.jl b/test/runtests.jl index 3725017..4faf94a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,17 +2,17 @@ using Romberg, Test @testset "Romberg.jl" begin # Test interfaces - x = range(0, π, length=2^8+1) + x = range(0, stop=π, length=2^8+1) y = sin.(x) @test romberg(x, y) == romberg(x, y, maxeval=9) # Test ispow2(length(x) - 1) == false - x = range(0, π, length=2^8) + x = range(0, stop=π, length=2^8) y = sin.(x) @test romberg(x, y)[1] ≈ 2 rtol=1e-12 - x = range(0, π, length=2^8-1) + x = range(0, stop=π, length=2^8-1) y = sin.(x) @test romberg(x, y)[1] ≈ 2 rtol=1e-9 @@ -22,31 +22,31 @@ using Romberg, Test @test romberg(x, y)[1] == 0 # Test length(x) == 2 - x = range(0, 1, length=2) + x = range(0, stop=1, length=2) y = x.^2 @test romberg(x,y)[1] == 0.5 # integration is inaccurate # Test length(x) == 3 - x = range(0, 1, length=3) + x = range(0, stop=1, length=3) y = x.^2 @test romberg(x, y)[1] ≈ 1/3 rtol=3e-16 # should be exact up to roundoff error # Integrate different functions - x = range(0, π, length=2^8+1) + x = range(0, stop=π, length=2^8+1) y = sin.(x) @test romberg(x, y)[1] ≈ 2 rtol=1e-15 - x = range(0, 1, length=2^8+1) + x = range(0, stop=1, length=2^8+1) y = x.^3 @test romberg(x, y)[1] ≈ 1/4 rtol=3e-16 # should be exact up to roundoff error - x = range(0, π/2, length=2^5+1) + x = range(0, stop=π/2, length=2^5+1) y = sin.(x).^2 @test romberg(x, y)[1] ≈ π/4 rtol=1e-15 m = 3 n = 4 - x = range(0, π, length=2^8+1) + x = range(0, stop=π, length=2^8+1) y = sin.(m*x).*cos.(n*x) v = romberg(x, y) @test v[1] ≈ 2*m/(m^2 - n^2) rtol=1e-13 @@ -57,18 +57,18 @@ using Romberg, Test # this one requires lots of samples... a = 15 - x = range(0, a, length=2^16+1) + x = range(0, stop=a, length=2^16+1) y = sqrt.(a^2 .- x.^2) @test romberg(x, y)[1] ≈ π*a^2/4 rtol=1e-8 # we can do much better if we put in the correct convergence # rate for this singular integrand, but this requires some # understanding of the theory that most people won't have… - x = range(0, a, length=2^7+1) + x = range(0, stop=a, length=2^7+1) y = sqrt.(a^2 .- x.^2) @test romberg(x, y, power=0.5)[1] ≈ π*a^2/4 rtol=1e-8 # tricky to integrate - x = range(1e-15, 1, length=2^16+1) + x = range(1e-15, stop=1, length=2^16+1) y = log.(x)./(1 .+ x) @test romberg(x, y)[1] ≈ -π^2/12 atol=1e-4