Skip to content

Commit

Permalink
Fix depwarns on 0.6 (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao authored and stevengj committed Feb 27, 2017
1 parent 73c92cd commit aac7416
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
6 changes: 4 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
environment:
matrix:
matrix:
- JULIAVERSION: "julialang/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe"
- JULIAVERSION: "julialang/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe"
- JULIAVERSION: "julialang/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe"
- JULIAVERSION: "julialang/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe"
- JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe"
- JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe"

Expand Down Expand Up @@ -32,7 +34,7 @@ install:
build_script:
# Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -F -e "versioninfo();
- C:\projects\julia\bin\julia -e "versioninfo();
Pkg.clone(pwd(), \"Cubature\"); Pkg.build(\"Cubature\")"

test_script:
Expand Down
8 changes: 4 additions & 4 deletions src/Cubature.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ const FAILURE = convert(Int32, 1)
# type to distinguish cubature error codes from thrown exceptions
type NoError <: Exception end # used for integrand_error when nothing thrown

type IntegrandData{F}
@compat type IntegrandData{F}
integrand_func::F
integrand_error::Any
IntegrandData(f) = new(f, NoError())
(::Type{IntegrandData{F}}){F}(f) = new{F}(f, NoError())
end
IntegrandData{F}(f::F) = IntegrandData{F}(f)

Expand Down Expand Up @@ -161,8 +161,8 @@ function cubature{F}(xscalar::Bool, fscalar::Bool,
end
xmin = Float64[xmin_...]
xmax = Float64[xmax_...]
val = Array(Float64, fdim)
err = Array(Float64, fdim)
val = Vector{Float64}(fdim)
err = Vector{Float64}(fdim)
d = IntegrandData(f)
fwrap = integrands(d, xscalar, fscalar, vectorized)
# ccall's first arg needs to be a constant expression, so
Expand Down
38 changes: 19 additions & 19 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ using Compat
# The downside of having multiple interfaces to simplify 1d, scalar
# integrands, etcetera, is that we have lot of interfaces to test:

@test_approx_eq_eps hquadrature(cos, 0,1, abstol=1e-8)[1] sin(1) 1e-8
@test_approx_eq_eps pquadrature(cos, 0,1, abstol=1e-8)[1] sin(1) 1e-8
@test isapprox(hquadrature(cos, 0,1, abstol=1e-8)[1], sin(1), atol=1e-8)
@test isapprox(pquadrature(cos, 0,1, abstol=1e-8)[1], sin(1), atol=1e-8)

quad_tst1(x) = @compat prod(cos.(x))
for dim = 0:3
xmin = zeros(dim)
xmax = 1:dim
ans = @compat prod(sin.(xmax))
@test_approx_eq_eps hcubature(quad_tst1, xmin,xmax, abstol=1e-8)[1] ans 1e-8
@test_approx_eq_eps pcubature(quad_tst1, xmin,xmax, abstol=1e-8)[1] ans 1e-8
@test isapprox(hcubature(quad_tst1, xmin,xmax, abstol=1e-8)[1], ans, atol=1e-8)
@test isapprox(pcubature(quad_tst1, xmin,xmax, abstol=1e-8)[1], ans, atol=1e-8)
end

quad_tst2(x, v) = for j = 1:length(v)
Expand All @@ -26,19 +26,19 @@ for dim = 0:3
xmax = 1:dim
ans = @compat prod(sin.(xmax)) * (1:fdim)
if dim == 1
@test_approx_eq_eps hquadrature(fdim, quad_tst2, xmin,xmax, abstol=1e-8)[1] ans 1e-8
@test_approx_eq_eps pquadrature(fdim, quad_tst2, xmin,xmax, abstol=1e-8)[1] ans 1e-8
@test isapprox(hquadrature(fdim, quad_tst2, xmin,xmax, abstol=1e-8)[1], ans, atol=1e-8)
@test isapprox(pquadrature(fdim, quad_tst2, xmin,xmax, abstol=1e-8)[1], ans, atol=1e-8)
end
@test_approx_eq_eps hcubature(fdim, quad_tst2, xmin,xmax, abstol=1e-8)[1] ans 1e-8
@test_approx_eq_eps pcubature(fdim, quad_tst2, xmin,xmax, abstol=1e-8)[1] ans 1e-8
@test isapprox(hcubature(fdim, quad_tst2, xmin,xmax, abstol=1e-8)[1], ans, atol=1e-8)
@test isapprox(pcubature(fdim, quad_tst2, xmin,xmax, abstol=1e-8)[1], ans, atol=1e-8)
end
end

quad_tst0v(x,v) = for i = 1:length(x)
v[i] = cos(x[i])
end
@test_approx_eq_eps hquadrature_v(quad_tst0v, 0,1, abstol=1e-8)[1] sin(1) 1e-8
@test_approx_eq_eps pquadrature_v(quad_tst0v, 0,1, abstol=1e-8)[1] sin(1) 1e-8
@test isapprox(hquadrature_v(quad_tst0v, 0,1, abstol=1e-8)[1], sin(1), atol=1e-8)
@test isapprox(pquadrature_v(quad_tst0v, 0,1, abstol=1e-8)[1], sin(1), atol=1e-8)

quad_tst1v(x,v) = for i = 1:length(v)
v[i] = @compat prod(cos.(x[:,i]))
Expand All @@ -47,8 +47,8 @@ for dim = 0:3
xmin = zeros(dim)
xmax = 1:dim
ans = @compat prod(sin.(xmax))
@test_approx_eq_eps hcubature_v(quad_tst1v, xmin,xmax, abstol=1e-8)[1] ans 1e-8
@test_approx_eq_eps pcubature_v(quad_tst1v, xmin,xmax, abstol=1e-8)[1] ans 1e-8
@test isapprox(hcubature_v(quad_tst1v, xmin,xmax, abstol=1e-8)[1], ans, atol=1e-8)
@test isapprox(pcubature_v(quad_tst1v, xmin,xmax, abstol=1e-8)[1], ans, atol=1e-8)
end

quad_tst2v(x::Array{Float64,2}, v) = for i = 1:size(v,2)
Expand All @@ -67,16 +67,16 @@ for dim = 0:3
xmax = 1:dim
ans = @compat prod(sin.(xmax)) * (1:fdim)
if dim == 1
@test_approx_eq_eps hquadrature_v(fdim, quad_tst2v, xmin,xmax, abstol=1e-8)[1] ans 1e-8
@test_approx_eq_eps pquadrature_v(fdim, quad_tst2v, xmin,xmax, abstol=1e-8)[1] ans 1e-8
@test isapprox(hquadrature_v(fdim, quad_tst2v, xmin,xmax, abstol=1e-8)[1], ans, atol=1e-8)
@test isapprox(pquadrature_v(fdim, quad_tst2v, xmin,xmax, abstol=1e-8)[1], ans, atol=1e-8)
end
@test_approx_eq_eps hcubature_v(fdim, quad_tst2v, xmin,xmax, abstol=1e-8)[1] ans 1e-8
@test_approx_eq_eps pcubature_v(fdim, quad_tst2v, xmin,xmax, abstol=1e-8)[1] ans 1e-8
@test isapprox(hcubature_v(fdim, quad_tst2v, xmin,xmax, abstol=1e-8)[1], ans, atol=1e-8)
@test isapprox(pcubature_v(fdim, quad_tst2v, xmin,xmax, abstol=1e-8)[1], ans, atol=1e-8)
end
end

# Check that nested calls work (although this is a suboptimal way to
# Check that nested calls work (although this is a suboptimal way to
# compute multidimensional integrals):

@test_approx_eq_eps hquadrature(x -> hquadrature(cos, 0,2, abstol=1e-8)[1]*cos(x),
0,1, abstol=1e-8)[1] sin(1)*sin(2) 1e-8
@test isapprox(hquadrature(x -> hquadrature(cos, 0,2, abstol=1e-8)[1]*cos(x),
0,1, abstol=1e-8)[1], sin(1)*sin(2), atol=1e-8)

0 comments on commit aac7416

Please sign in to comment.