From 92bddf4eb34284a845c40e333b37bda2a711f99e Mon Sep 17 00:00:00 2001 From: monty Date: Thu, 9 Feb 2017 07:31:06 -0700 Subject: [PATCH] minor --- test/testfd.jl | 9 ++++----- test/testfftrf.jl | 15 +++++++-------- test/testrmf.jl | 21 ++++++++++----------- test/testrpcga.jl | 2 +- 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/test/testfd.jl b/test/testfd.jl index 7aac77e..dbd139d 100644 --- a/test/testfd.jl +++ b/test/testfd.jl @@ -1,6 +1,5 @@ import GeostatInversion -const FDDerivatives = GeostatInversion.FDDerivatives -using Base.Test +import Base.Test function basictest() function f(x::Array{Float64, 1}) @@ -9,12 +8,12 @@ function basictest() function jacobianf(x::Array{Float64, 1}) return [1. .5; 2 * x[1] 0.; 0. cos(x[2]); -sin(x[1]) 0.] end - testjacobianf = FDDerivatives.makejacobian(f) + testjacobianf = GeostatInversion.FDDerivatives.makejacobian(f) x = [1., 2.] - @test_approx_eq_eps jacobianf(x) testjacobianf(x) 1e-4 + @Base.Test.test_approx_eq_eps jacobianf(x) testjacobianf(x) 1e-4 for i = 1:10000 x = 10 * randn(2) - @test_approx_eq_eps jacobianf(x) testjacobianf(x) 1e-4 + @Base.Test.test_approx_eq_eps jacobianf(x) testjacobianf(x) 1e-4 end end diff --git a/test/testfftrf.jl b/test/testfftrf.jl index 31c1435..97c5e2f 100644 --- a/test/testfftrf.jl +++ b/test/testfftrf.jl @@ -1,16 +1,15 @@ -using Base.Test import GeostatInversion -const FFTRF = GeostatInversion.FFTRF +import Base.Test function testNd(N) Ns = map(x->round(Int, 25 * x), 1 + rand(N)) k0 = randn() dk = rand() beta = -2 - rand() - k = FFTRF.powerlaw_structuredgrid(Ns, k0, dk, beta) - @test_approx_eq mean(k) k0 - @test_approx_eq std(k) dk - @test collect(size(k)) == Ns + k = GeostatInversion.FFTRF.powerlaw_structuredgrid(Ns, k0, dk, beta) + @Base.Test.test_approx_eq mean(k) k0 + @Base.Test.test_approx_eq std(k) dk + @Base.Test.test collect(size(k)) == Ns end function testunstructured(N) @@ -19,8 +18,8 @@ function testunstructured(N) k0 = randn() dk = rand() beta = -2 - rand() - k = FFTRF.powerlaw_unstructuredgrid(points, Ns, k0, dk, beta) - @test length(k) == size(points, 2) + k = GeostatInversion.FFTRF.powerlaw_unstructuredgrid(points, Ns, k0, dk, beta) + @Base.Test.test length(k) == size(points, 2) end srand(0) diff --git a/test/testrmf.jl b/test/testrmf.jl index 9814f27..008b8f5 100644 --- a/test/testrmf.jl +++ b/test/testrmf.jl @@ -1,6 +1,5 @@ import GeostatInversion -const RandMatFact = GeostatInversion.RandMatFact -using Base.Test +import Base.Test function makeA(n, m) range = randn(n, m) @@ -10,22 +9,22 @@ end function test_rangefinder(n, m) A = makeA(n, m) - Q = RandMatFact.rangefinder(A) - @test_approx_eq_eps m size(Q, 2) 1 - @test_approx_eq_eps vecnorm(A - Q * ctranspose(Q) * A) 0. 1e-8 - Q = RandMatFact.rangefinder(A, m, 2) - @test_approx_eq_eps m size(Q, 2) 1 - @test_approx_eq_eps vecnorm(A - Q * ctranspose(Q) * A) 0. 1e-8 + Q = GeostatInversion.RandMatFact.rangefinder(A) + @Base.Test.test_approx_eq_eps m size(Q, 2) 1 + @Base.Test.test_approx_eq_eps vecnorm(A - Q * ctranspose(Q) * A) 0. 1e-8 + Q = GeostatInversion.RandMatFact.rangefinder(A, m, 2) + @Base.Test.test_approx_eq_eps m size(Q, 2) 1 + @Base.Test.test_approx_eq_eps vecnorm(A - Q * ctranspose(Q) * A) 0. 1e-8 end function test_eig_nystrom() A = Float64[2 -1 0; -1 2 -1; 0 -1 2] - Q = RandMatFact.rangefinder(A) - U, Sigmavec = RandMatFact.eig_nystrom(A, Q) + Q = GeostatInversion.RandMatFact.rangefinder(A) + U, Sigmavec = GeostatInversion.RandMatFact.eig_nystrom(A, Q) Sigma = diagm(Sigmavec) Lambda = Sigma * Sigma eigvals, eigvecs = eig(A) - @test_approx_eq_eps vecnorm(sort(eigvals, rev=true) - diag(Lambda)) 0. 1e-8 + @Base.Test.test_approx_eq_eps vecnorm(sort(eigvals, rev=true) - diag(Lambda)) 0. 1e-8 end test_rangefinder(10, 2) diff --git a/test/testrpcga.jl b/test/testrpcga.jl index 6bd4d90..56dc43d 100644 --- a/test/testrpcga.jl +++ b/test/testrpcga.jl @@ -23,7 +23,7 @@ function simplepcgalowranktest(numetas=10, numobs=20) for i = 1:numobs + 1 x = zeros(numobs + 1) x[i] = 1. - @test_approx_eq bigA * x lrbigA * x + @Base.Test.test_approx_eq bigA * x lrbigA * x end end end