-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update tests; bug fixes; drop pre-1.0 support (#153)
- Loading branch information
Showing
21 changed files
with
1,485 additions
and
578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ os: | |
- osx | ||
- linux | ||
julia: | ||
- 0.6 | ||
- 0.7 | ||
- 1.0 | ||
- 1.1 | ||
- nightly | ||
matrix: | ||
allow_failures: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
julia 0.6.0 | ||
Compat 0.59.0 | ||
julia 1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
SpecialFunctions 0.1.1 | ||
SpecialFunctions 0.1.1 | ||
JSON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# v1.0 only | ||
# Import dependency. | ||
using BenchmarkTools, Roots, Statistics | ||
|
||
#Create benchmark group and benchmarks | ||
benchmarks = BenchmarkGroup() | ||
|
||
#Put in specific benchmarks | ||
|
||
bracket_methods = (bisection=Roots.Bisection(), a42=Roots.A42(), | ||
aps=Roots.AlefeldPotraShi()) | ||
derivative_free_methods = (o0=Roots.Order0(), o1=Roots.Order1(), o1b=Roots.Order1B(), | ||
o2=Roots.Order2(), o2b=Roots.Order2B(), | ||
o5=Roots.Order5(), o8=Roots.Order8(), o16=Roots.Order16() | ||
) | ||
|
||
# collection of doable problems | ||
problems = Dict("f1" => (x -> sin(x), 3.0, (3.0, 4.0)), | ||
"f2" => (x -> x^5 - x - 1, 1.0, (0.5, 5.0)), | ||
"f3" => (x -> exp(x) - x^4, 7.0, (5.0, 20.0)), | ||
"f4" => (x -> cos(x) - x/2, pi/4, (0.0, pi/2)), | ||
"f5" => (x -> x^2 - exp(x) - 3x + 2, -0.5, (-1.0, 1.0)), | ||
"f6" => (x -> x^2 - exp(x) - 3x + 2, 2.0, (0.0, 3.0)), | ||
"f7" => (x -> tanh(x) - tan(x), 7.6, (4.0, 8.0)), | ||
"f8" => (x -> exp(-x^2 + x + 2) - cos(x) + x^3 + 1, -0.5, (-2.0, 1.0)), | ||
"f9" => (x -> log(x) + sqrt(x) - 5, 7, (7.0, 10.0)), | ||
"f10" => (x -> log(x) + sqrt(x) - 5, 20, (7.0, 10.0)) | ||
) | ||
|
||
function run_bracket(problems, Ms) | ||
|
||
for (nm, prob) in problems | ||
fn, x0, ab = prob | ||
for (mnm, M) in zip(fieldnames(typeof(Ms)), Ms) | ||
find_zero(fn, ab, M) | ||
end | ||
end | ||
|
||
end | ||
|
||
function run_bracketing(problems, Ms) | ||
rts = Float64[] | ||
for (nm, prob) in problems | ||
fn, x0, ab = prob | ||
for M in Ms | ||
rt = find_zero(fn, ab) | ||
push!(rts, rt) | ||
end | ||
end | ||
rts | ||
|
||
end | ||
|
||
function run_derivative_free(problems, Ms) | ||
rts = Float64[] | ||
for (nm, prob) in problems | ||
fn, x0, ab = prob | ||
for M in Ms | ||
rt = find_zero(fn, x0, M) | ||
push!(rts, rt) | ||
end | ||
end | ||
rts | ||
|
||
end | ||
|
||
function run_simple(problems) | ||
rts = Float64[] | ||
for (nm, prob) in problems | ||
fn, x0, ab = prob | ||
push!(rts, Roots.bisection(fn, ab[1], ab[2])) | ||
push!(rts, Roots.bisection(fn, ab[1], ab[2], xatol=1e-6)) | ||
push!(rts, Roots.secant_method(fn, x0)) | ||
end | ||
rts | ||
end | ||
|
||
|
||
benchmarks = BenchmarkGroup() | ||
|
||
benchmarks["bracketing"] = @benchmarkable run_bracketing($problems, $bracket_methods) | ||
benchmarks["derivative_free"] = @benchmarkable run_derivative_free($problems, $derivative_free_methods) | ||
benchmarks["simple"] = @benchmarkable run_simple($problems) | ||
|
||
|
||
|
||
|
||
for (nm, prob) in problems | ||
fn, x0, ab = prob | ||
@assert fn(ab[1]) * fn(ab[2]) < 0 | ||
|
||
Ms = bracket_methods | ||
for (mnm, M) in zip(fieldnames(typeof(Ms)), Ms) | ||
benchmarks[nm * "-" * string(mnm)] = @benchmarkable find_zero($fn, $ab, $M) | ||
end | ||
|
||
Ms = derivative_free_methods | ||
for (mnm, M) in zip(fieldnames(typeof(Ms)), Ms) | ||
benchmarks[nm * "-" * string(mnm)] = @benchmarkable find_zero($fn, $x0, $M) | ||
end | ||
|
||
# simple methods | ||
u,v = ab | ||
benchmarks[nm * "-bisection"] = @benchmarkable Roots.bisection($fn, $u, $v) | ||
benchmarks[nm * "-bisection-atol"] = @benchmarkable Roots.bisection($fn, $u, $v, xatol=1e-6) | ||
benchmarks[nm * "-secant"] = @benchmarkable Roots.secant_method($fn, $x0) | ||
end | ||
|
||
results = run(benchmarks) # Get results. | ||
results = median(results) # Condense to median. | ||
|
||
nm = "benchmarks.json" | ||
fname = joinpath(@__DIR__, nm) | ||
if isinteractive() | ||
println(""" | ||
To save results, manually call in the REPL: BenchmarkTools.save("benchmarks.json", results) | ||
""") | ||
end | ||
|
||
#Compare to old results | ||
try | ||
oldresults= BenchmarkTools.load(fname)[1] | ||
judge(oldresults, results) | ||
catch err | ||
error("Couldn't load file- make sure that you've previously saved results.", err.prefix) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
using Roots | ||
using Compat.Test | ||
using Test | ||
import SpecialFunctions.erf | ||
|
||
include("./test_find_zero.jl") | ||
include("./test_fzero.jl") | ||
include("./test_bracketing.jl") | ||
include("./test_derivative_free.jl") | ||
include("./test_simple.jl") | ||
include("./test_find_zeros.jl") | ||
include("./test_fzero.jl") | ||
include("./test_newton.jl") | ||
include("./test_simple.jl") | ||
include("./RootTesting.jl") | ||
|
||
#include("./test_composable.jl") | ||
|
||
#run_benchmark_tests() | ||
|
||
#include("./test_fzero3.jl") | ||
#run_robustness_test() | ||
|
||
#include("./test_derivative_free.jl") | ||
#include("./runbenchmarks.jl") | ||
#include("./test_derivative_free_interactive.jl") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# that CI should run these | ||
|
||
using Roots | ||
using Compat.Test | ||
using Test | ||
using Unitful | ||
using SymEngine | ||
|
||
|
Oops, something went wrong.