From d6edd545c7c57b4ae149ba5c814f153d795ec108 Mon Sep 17 00:00:00 2001 From: Andreas Noack Date: Wed, 18 Jan 2017 14:11:51 -0500 Subject: [PATCH] Use Int instead of Int64 in function signatures and test integer input (#26) --- src/rmath.jl | 4 ++-- test/rmath.jl | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/rmath.jl b/src/rmath.jl index 3e6ddfb..a5d5db2 100644 --- a/src/rmath.jl +++ b/src/rmath.jl @@ -53,10 +53,10 @@ function _import_rmath(rname::Symbol, jname::Symbol, pargs) # function implementation quote - $pdf($(pdecls...), x::Union{Float64,Int64}) = + $pdf($(pdecls...), x::Union{Float64,Int}) = ccall(($dfun, libRmath), Float64, $dtypes, x, $(pargs...), 0) - $logpdf($(pdecls...), x::Union{Float64,Int64}) = + $logpdf($(pdecls...), x::Union{Float64,Int}) = ccall(($dfun, libRmath), Float64, $dtypes, x, $(pargs...), 1) $cdf($(pdecls...), x::Real) = diff --git a/test/rmath.jl b/test/rmath.jl index 1767f93..18d3bee 100644 --- a/test/rmath.jl +++ b/test/rmath.jl @@ -118,6 +118,7 @@ rmathcomp_tests("beta", [ ((1.0, 1.0), 0.01:0.01:0.99), ((2.0, 3.0), 0.01:0.01:0.99), ((10.0, 2.0), 0.01:0.01:0.99), + ((10, 2), 0.01:0.01:0.99), ]) rmathcomp_tests("binom", [ @@ -126,12 +127,14 @@ rmathcomp_tests("binom", [ ((8, 0.6), 0.0:8.0), ((20, 0.1), 0.0:20.0), ((20, 0.9), 0.0:20.0), + ((20, 0.9), 0:20), ]) rmathcomp_tests("chisq", [ ((1,), 0.0:0.1:8.0), ((4,), 0.0:0.1:8.0), ((9,), 0.0:0.1:8.0), + ((9,), 0:8), ]) rmathcomp_tests("fdist", [ @@ -140,6 +143,7 @@ rmathcomp_tests("fdist", [ ((5, 2), (0.0:0.1:5.0)), ((10, 1), (0.0:0.1:5.0)), ((10, 3), (0.0:0.1:5.0)), + ((10, 3), (0:5)), ]) rmathcomp_tests("gamma", [ @@ -148,10 +152,12 @@ rmathcomp_tests("gamma", [ ((3.0, 1.0), (0.05:0.05:12.0)), ((9.0, 1.0), (0.05:0.05:12.0)), ((2.0, 3.0), (0.05:0.05:12.0)), + ((2, 3), (1:12)), ]) rmathcomp_tests("hyper", [ - ((2, 3, 4), 0.0:4.0) + ((2, 3, 4), 0.0:4.0), + ((2, 3, 4), 0:4) ]) rmathcomp_tests("nbeta", [ @@ -159,6 +165,7 @@ rmathcomp_tests("nbeta", [ ((2.0, 3.0, 0.0), 0.01:0.01:0.99), ((1.0, 1.0, 2.0), 0.01:0.01:0.99), ((3.0, 4.0, 2.0), 0.01:0.01:0.99), + ((3, 4, 2), 0.01:0.01:0.99), ]) rmathcomp_tests("nbinom", [ @@ -166,6 +173,7 @@ rmathcomp_tests("nbinom", [ ((3, 0.5), 0.0:20.0), ((3, 0.2), 0.0:20.0), ((3, 0.8), 0.0:20.0), + ((3, 0.8), 0:20), ]) rmathcomp_tests("nchisq", [ @@ -173,12 +181,14 @@ rmathcomp_tests("nchisq", [ ((2, 3), 0.0:0.2:8.0), ((4, 1), 0.0:0.2:8.0), ((4, 3), 0.0:0.2:8.0), + ((4, 3), 0:8), ]) rmathcomp_tests("nfdist", [ ((1.0, 1.0, 0.0), 0.1:0.1:10.0), ((1.0, 1.0, 2.0), 0.1:0.1:10.0), ((2.0, 3.0, 1.0), 0.1:0.1:10.0), + ((2, 3, 1), 1:10), ]) rmathcomp_tests("norm", [ @@ -186,7 +196,8 @@ rmathcomp_tests("norm", [ ((2.0, 1.0), -3.0:0.01:7.0), ((0.0, 0.5), -3.0:0.01:3.0), ((0, 1), -3.0:3.0), - ((0, 1), -3.0:0.01:3.0) + ((0, 1), -3.0:0.01:3.0), + ((0, 1), -3:3) ]) rmathcomp_tests("ntdist", [ @@ -194,6 +205,7 @@ rmathcomp_tests("ntdist", [ ((0, 4), -4.0:0.1:10.0), ((2, 1), -4.0:0.1:10.0), ((2, 4), -4.0:0.1:10.0), + ((2, 4), -4:10), ]) rmathcomp_tests("pois", [ @@ -201,10 +213,12 @@ rmathcomp_tests("pois", [ ((1.0,), 0.0:20.0), ((2.0,), 0.0:20.0), ((10.0,), 0.0:20.0), + ((10,), 0:20), ]) rmathcomp_tests("tdist", [ ((1,), -5.0:0.1:5.0), ((2,), -5.0:0.1:5.0), ((5,), -5.0:0.1:5.0), + ((5,), -5:5), ])