Skip to content

Commit

Permalink
Merge pull request #39 from JuliaStats/anj/vec
Browse files Browse the repository at this point in the history
Remove remaining uses of Compat
  • Loading branch information
andreasnoack authored Aug 9, 2017
2 parents d75743b + d1d0e8b commit 136d37f
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 145 deletions.
2 changes: 1 addition & 1 deletion deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BinDeps, Compat
using BinDeps

@BinDeps.setup

Expand Down
267 changes: 123 additions & 144 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Base.Test
using Rmath
using Compat

srand(124)

Expand All @@ -9,8 +8,8 @@ function allEq(target::Vector{Float64}, current::Vector{Float64}, tolerance::Flo
if all(target == current)
return true
end
xy = @compat mean(abs.(target .- current))
xn = @compat mean(abs.(target))
xy = mean(abs.(target .- current))
xn = mean(abs.(target))
if (isfinite(xn) && xn > tolerance)
xy /= xn
end
Expand Down Expand Up @@ -46,156 +45,136 @@ allEq(target::Vector{Float64}, current::Vector{Float64}) =

const n = 26

const Rbeta = rbeta(n, .8, 2)
const Rbinom = rbinom(n, 55, pi/16)
const Rcauchy = rcauchy(n, 12, 2)
const Rchisq = rchisq(n, 3)
const Rexp = rexp(n, 2)
const Rf = rf(n, 12, 6)
const Rgamma = rgamma(n, 2, 5)
const Rgeom = rgeom(n, pi/16)
const Rhyper = rhyper(n, 40, 30, 20)
const Rlnorm = rlnorm(n, -1, 3)
const Rlogis = rlogis(n, 12, 2)
const Rnbinom = rnbinom(n, 7, .01)
const Rnorm = rnorm(n, -1, 3)
const Rpois = rpois(n, 12)
const Rsignrank = rsignrank(n, 47)
const Rt = rt(n, 11)
const Rbeta = rbeta(n, .8, 2)
const Rbinom = rbinom(n, 55, pi/16)
const Rcauchy = rcauchy(n, 12, 2)
const Rchisq = rchisq(n, 3)
const Rexp = rexp(n, 2)
const Rf = rf(n, 12, 6)
const Rgamma = rgamma(n, 2, 5)
const Rgeom = rgeom(n, pi/16)
const Rhyper = rhyper(n, 40, 30, 20)
const Rlnorm = rlnorm(n, -1, 3)
const Rlogis = rlogis(n, 12, 2)
const Rnbinom = rnbinom(n, 7, .01)
const Rnorm = rnorm(n, -1, 3)
const Rpois = rpois(n, 12)
const Rsignrank = rsignrank(n, 47)
const Rt = rt(n, 11)
## Rt2 below (to preserve the following random numbers!)
const Runif = runif(n, .2, 2)
const Rweibull = rweibull(n, 3, 2)
const Rwilcox = rwilcox(n, 13, 17)
const Rt2 = rt(n, 1.01)

const Pbeta = @compat pbeta.(Rbeta, .8, 2)
const Pbinom = @compat pbinom.(Rbinom, 55, pi/16)
const Pcauchy = @compat pcauchy.(Rcauchy, 12, 2)
const Pchisq = @compat pchisq.(Rchisq, 3)
const Pexp = @compat pexp.(Rexp, 2)
const Pf = @compat pf.(Rf, 12, 6)
const Pgamma = @compat pgamma.(Rgamma, 2, 5)
const Pgeom = @compat pgeom.(Rgeom, pi/16)
const Phyper = @compat phyper.(Rhyper, 40, 30, 20)
const Plnorm = @compat plnorm.(Rlnorm, -1, 3)
const Plogis = @compat plogis.(Rlogis, 12, 2)
const Pnbinom = @compat pnbinom.(Rnbinom, 7, .01)
const Pnorm = @compat pnorm.(Rnorm, -1, 3)
const Ppois = @compat ppois.(Rpois, 12)
const Psignrank = @compat psignrank.(Rsignrank, 47)
const Pt = @compat pt.(Rt, 11)
const Pt2 = @compat pt.(Rt2, 1.01)
const Punif = @compat punif.(Runif, .2, 2)
const Pweibull = @compat pweibull.(Rweibull, 3, 2)
const Pwilcox = @compat pwilcox.(Rwilcox, 13, 17)

@compat dbeta.(Rbeta, .8, 2)
@compat dbinom.(Rbinom, 55, pi/16)
@compat dcauchy.(Rcauchy, 12, 2)
@compat dchisq.(Rchisq, 3)
@compat dexp.(Rexp, 2)
@compat df.(Rf, 12, 6)
@compat dgamma.(Rgamma, 2, 5)
@compat dgeom.(Rgeom, pi/16)
@compat dhyper.(Rhyper, 40, 30, 20)
@compat dlnorm.(Rlnorm, -1, 3)
@compat dlogis.(Rlogis, 12, 2)
@compat dnbinom.(Rnbinom, 7, .01)
@compat dnorm.(Rnorm, -1, 3)
@compat dpois.(Rpois, 12)
@compat dsignrank.(Rsignrank, 47)
@compat dt.(Rt, 11)
@compat dunif.(Runif, .2, 2)
@compat dweibull.(Rweibull, 3, 2)
@compat dwilcox.(Rwilcox, 13, 17)
const Runif = runif(n, .2, 2)
const Rweibull = rweibull(n, 3, 2)
const Rwilcox = rwilcox(n, 13, 17)
const Rt2 = rt(n, 1.01)

const Pbeta = pbeta.(Rbeta, .8, 2)
const Pbinom = pbinom.(Rbinom, 55, pi/16)
const Pcauchy = pcauchy.(Rcauchy, 12, 2)
const Pchisq = pchisq.(Rchisq, 3)
const Pexp = pexp.(Rexp, 2)
const Pf = pf.(Rf, 12, 6)
const Pgamma = pgamma.(Rgamma, 2, 5)
const Pgeom = pgeom.(Rgeom, pi/16)
const Phyper = phyper.(Rhyper, 40, 30, 20)
const Plnorm = plnorm.(Rlnorm, -1, 3)
const Plogis = plogis.(Rlogis, 12, 2)
const Pnbinom = pnbinom.(Rnbinom, 7, .01)
const Pnorm = pnorm.(Rnorm, -1, 3)
const Ppois = ppois.(Rpois, 12)
const Psignrank = psignrank.(Rsignrank, 47)
const Pt = pt.(Rt, 11)
const Pt2 = pt.(Rt2, 1.01)
const Punif = punif.(Runif, .2, 2)
const Pweibull = pweibull.(Rweibull, 3, 2)
const Pwilcox = pwilcox.(Rwilcox, 13, 17)

## Check q*(p*(.)) = identity
@compat allEq(Rbeta, qbeta.(Pbeta, .8, 2))
@compat allEq(Rbinom, qbinom.(Pbinom, 55, pi/16))
@compat allEq(Rcauchy, qcauchy.(Pcauchy, 12, 2))
@compat allEq(Rchisq, qchisq.(Pchisq, 3))
@compat allEq(Rexp, qexp.(Pexp, 2))
@compat allEq(Rf, qf.(Pf, 12, 6))
@compat allEq(Rgamma, qgamma.(Pgamma, 2, 5))
@compat allEq(Rgeom, qgeom.(Pgeom, pi/16))
@compat allEq(Rhyper, qhyper.(Phyper, 40, 30, 20))
@compat allEq(Rlnorm, qlnorm.(Plnorm, -1, 3))
@compat allEq(Rlogis, qlogis.(Plogis, 12, 2))
@compat allEq(Rnbinom, qnbinom.(Pnbinom, 7, .01))
@compat allEq(Rnorm, qnorm.(Pnorm, -1, 3))
@compat allEq(Rpois, qpois.(Ppois, 12))
@compat allEq(Rsignrank, qsignrank.(Psignrank, 47))
@compat allEq(Rt, qt.(Pt, 11))
@compat allEq(Rt2, qt.(Pt2, 1.01), 1e-2)
@compat allEq(Runif, qunif.(Punif, .2, 2))
@compat allEq(Rweibull, qweibull.(Pweibull, 3, 2))
@compat allEq(Rwilcox, qwilcox.(Pwilcox, 13, 17))
allEq(Rbeta, qbeta.(Pbeta, .8, 2))
allEq(Rbinom, qbinom.(Pbinom, 55, pi/16))
allEq(Rcauchy, qcauchy.(Pcauchy, 12, 2))
allEq(Rchisq, qchisq.(Pchisq, 3))
allEq(Rexp, qexp.(Pexp, 2))
allEq(Rf, qf.(Pf, 12, 6))
allEq(Rgamma, qgamma.(Pgamma, 2, 5))
allEq(Rgeom, qgeom.(Pgeom, pi/16))
allEq(Rhyper, qhyper.(Phyper, 40, 30, 20))
allEq(Rlnorm, qlnorm.(Plnorm, -1, 3))
allEq(Rlogis, qlogis.(Plogis, 12, 2))
allEq(Rnbinom, qnbinom.(Pnbinom, 7, .01))
allEq(Rnorm, qnorm.(Pnorm, -1, 3))
allEq(Rpois, qpois.(Ppois, 12))
allEq(Rsignrank, qsignrank.(Psignrank, 47))
allEq(Rt, qt.(Pt, 11))
allEq(Rt2, qt.(Pt2, 1.01), 1e-2)
allEq(Runif, qunif.(Punif, .2, 2))
allEq(Rweibull, qweibull.(Pweibull, 3, 2))
allEq(Rwilcox, qwilcox.(Pwilcox, 13, 17))

## Same with "upper tail":
@compat allEq(Rbeta, qbeta.(1 .- Pbeta, .8, 2, false))
@compat allEq(Rbinom, qbinom.(1 .- Pbinom, 55, pi/16, false))
@compat allEq(Rcauchy, qcauchy.(1 .- Pcauchy, 12, 2, false))
@compat allEq(Rchisq, qchisq.(1 .- Pchisq, 3, false))
@compat allEq(Rexp, qexp.(1 .- Pexp, 2, false))
@compat allEq(Rf, qf.(1 .- Pf, 12, 6, false))
@compat allEq(Rgamma, qgamma.(1 .- Pgamma, 2, 5, false))
@compat allEq(Rgeom, qgeom.(1 .- Pgeom, pi/16, false))
@compat allEq(Rhyper, qhyper.(1 .- Phyper, 40, 30, 20, false))
@compat allEq(Rlnorm, qlnorm.(1 .- Plnorm, -1, 3, false))
@compat allEq(Rlogis, qlogis.(1 .- Plogis, 12, 2, false))
@compat allEq(Rnbinom, qnbinom.(1 .- Pnbinom, 7, .01, false))
@compat allEq(Rnorm, qnorm.(1 .- Pnorm, -1, 3,false))
@compat allEq(Rpois, qpois.(1 .- Ppois, 12, false))
@compat allEq(Rsignrank, qsignrank.(1 .- Psignrank, 47, false))
@compat allEq(Rt, qt.(1 .- Pt, 11, false))
@compat allEq(Rt2, qt.(1 .- Pt2, 1.01, false), 1e-2)
@compat allEq(Runif, qunif.(1 .- Punif, .2, 2, false))
@compat allEq(Rweibull, qweibull.(1 .- Pweibull, 3, 2, false))
@compat allEq(Rwilcox, qwilcox.(1 .- Pwilcox, 13, 17, false))
allEq(Rbeta, qbeta.(1 .- Pbeta, .8, 2, false))
allEq(Rbinom, qbinom.(1 .- Pbinom, 55, pi/16, false))
allEq(Rcauchy, qcauchy.(1 .- Pcauchy, 12, 2, false))
allEq(Rchisq, qchisq.(1 .- Pchisq, 3, false))
allEq(Rexp, qexp.(1 .- Pexp, 2, false))
allEq(Rf, qf.(1 .- Pf, 12, 6, false))
allEq(Rgamma, qgamma.(1 .- Pgamma, 2, 5, false))
allEq(Rgeom, qgeom.(1 .- Pgeom, pi/16, false))
allEq(Rhyper, qhyper.(1 .- Phyper, 40, 30, 20, false))
allEq(Rlnorm, qlnorm.(1 .- Plnorm, -1, 3, false))
allEq(Rlogis, qlogis.(1 .- Plogis, 12, 2, false))
allEq(Rnbinom, qnbinom.(1 .- Pnbinom, 7, .01, false))
allEq(Rnorm, qnorm.(1 .- Pnorm, -1, 3,false))
allEq(Rpois, qpois.(1 .- Ppois, 12, false))
allEq(Rsignrank, qsignrank.(1 .- Psignrank, 47, false))
allEq(Rt, qt.(1 .- Pt, 11, false))
allEq(Rt2, qt.(1 .- Pt2, 1.01, false), 1e-2)
allEq(Runif, qunif.(1 .- Punif, .2, 2, false))
allEq(Rweibull, qweibull.(1 .- Pweibull, 3, 2, false))
allEq(Rwilcox, qwilcox.(1 .- Pwilcox, 13, 17, false))

## Check q*(p* ( log ), log) = identity
@compat allEq(Rbeta, qbeta.(log.(Pbeta), .8, 2, true, true))
@compat allEq(Rbinom, qbinom.(log.(Pbinom), 55, pi/16, true, true))
@compat allEq(Rcauchy, qcauchy.(log.(Pcauchy), 12, 2, true, true))
@compat allEq(Rchisq, qchisq.(log.(Pchisq), 3, true, true), 1e-14)
@compat allEq(Rexp, qexp.(log.(Pexp), 2, true, true))
@compat allEq(Rf, qf.(log.(Pf), 12, 6, true, true))
@compat allEq(Rgamma, qgamma.(log.(Pgamma), 2, 5, true, true))
@compat allEq(Rgeom, qgeom.(log.(Pgeom), pi/16, true, true))
@compat allEq(Rhyper, qhyper.(log.(Phyper), 40, 30, 20, true, true))
@compat allEq(Rlnorm, qlnorm.(log.(Plnorm), -1, 3, true, true))
@compat allEq(Rlogis, qlogis.(log.(Plogis), 12, 2, true, true))
@compat allEq(Rnbinom, qnbinom.(log.(Pnbinom), 7, .01, true, true))
@compat allEq(Rnorm, qnorm.(log.(Pnorm), -1, 3, true, true))
@compat allEq(Rpois, qpois.(log.(Ppois), 12, true, true))
@compat allEq(Rsignrank, qsignrank.(log.(Psignrank), 47, true, true))
@compat allEq(Rt, qt.(log.(Pt), 11, true, true))
@compat allEq(Rt2, qt.(log.(Pt2), 1.01, true, true), 1e-2)
@compat allEq(Runif, qunif.(log.(Punif), .2, 2, true, true))
@compat allEq(Rweibull, qweibull.(log.(Pweibull), 3, 2, true, true))
@compat allEq(Rwilcox, qwilcox.(log.(Pwilcox), 13, 17, true, true))
allEq(Rbeta, qbeta.(log.(Pbeta), .8, 2, true, true))
allEq(Rbinom, qbinom.(log.(Pbinom), 55, pi/16, true, true))
allEq(Rcauchy, qcauchy.(log.(Pcauchy), 12, 2, true, true))
allEq(Rchisq, qchisq.(log.(Pchisq), 3, true, true), 1e-14)
allEq(Rexp, qexp.(log.(Pexp), 2, true, true))
allEq(Rf, qf.(log.(Pf), 12, 6, true, true))
allEq(Rgamma, qgamma.(log.(Pgamma), 2, 5, true, true))
allEq(Rgeom, qgeom.(log.(Pgeom), pi/16, true, true))
allEq(Rhyper, qhyper.(log.(Phyper), 40, 30, 20, true, true))
allEq(Rlnorm, qlnorm.(log.(Plnorm), -1, 3, true, true))
allEq(Rlogis, qlogis.(log.(Plogis), 12, 2, true, true))
allEq(Rnbinom, qnbinom.(log.(Pnbinom), 7, .01, true, true))
allEq(Rnorm, qnorm.(log.(Pnorm), -1, 3, true, true))
allEq(Rpois, qpois.(log.(Ppois), 12, true, true))
allEq(Rsignrank, qsignrank.(log.(Psignrank), 47, true, true))
allEq(Rt, qt.(log.(Pt), 11, true, true))
allEq(Rt2, qt.(log.(Pt2), 1.01, true, true), 1e-2)
allEq(Runif, qunif.(log.(Punif), .2, 2, true, true))
allEq(Rweibull, qweibull.(log.(Pweibull), 3, 2, true, true))
allEq(Rwilcox, qwilcox.(log.(Pwilcox), 13, 17, true, true))

## same q*(p* (log) log) with upper tail:
@compat allEq(Rbeta, qbeta.(log.(1 .- Pbeta), .8, 2, false, true))
@compat allEq(Rbinom, qbinom.(log.(1 .- Pbinom), 55, pi/16, false, true))
@compat allEq(Rcauchy, qcauchy.(log.(1 .- Pcauchy), 12, 2, false, true))
@compat allEq(Rchisq, qchisq.(log.(1 .- Pchisq), 3, false, true))
@compat allEq(Rexp, qexp.(log.(1 .- Pexp), 2, false, true))
@compat allEq(Rf, qf.(log.(1 .- Pf), 12, 6, false, true))
@compat allEq(Rgamma, qgamma.(log.(1 .- Pgamma), 2, 5, false, true))
@compat allEq(Rgeom, qgeom.(log.(1 .- Pgeom), pi/16, false, true))
@compat allEq(Rhyper, qhyper.(log.(1 .- Phyper), 40, 30, 20, false, true))
@compat allEq(Rlnorm, qlnorm.(log.(1 .- Plnorm), -1, 3, false, true))
@compat allEq(Rlogis, qlogis.(log.(1 .- Plogis), 12, 2, false, true))
@compat allEq(Rnbinom, qnbinom.(log.(1 .- Pnbinom), 7, .01, false, true))
@compat allEq(Rnorm, qnorm.(log.(1 .- Pnorm), -1, 3, false, true))
@compat allEq(Rpois, qpois.(log.(1 .- Ppois), 12, false, true))
@compat allEq(Rsignrank, qsignrank.(log.(1 .- Psignrank), 47, false, true))
@compat allEq(Rt, qt.(log.(1 .- Pt ), 11, false, true))
@compat allEq(Rt2, qt.(log.(1 .- Pt2), 1.01, false, true), 1e-2)
@compat allEq(Runif, qunif.(log.(1 .- Punif), .2, 2, false, true))
@compat allEq(Rweibull, qweibull.(log.(1 .- Pweibull), 3, 2, false, true))
@compat allEq(Rwilcox, qwilcox.(log.(1 .- Pwilcox), 13, 17, false, true))
allEq(Rbeta, qbeta.(log.(1 .- Pbeta), .8, 2, false, true))
allEq(Rbinom, qbinom.(log.(1 .- Pbinom), 55, pi/16, false, true))
allEq(Rcauchy, qcauchy.(log.(1 .- Pcauchy), 12, 2, false, true))
allEq(Rchisq, qchisq.(log.(1 .- Pchisq), 3, false, true))
allEq(Rexp, qexp.(log.(1 .- Pexp), 2, false, true))
allEq(Rf, qf.(log.(1 .- Pf), 12, 6, false, true))
allEq(Rgamma, qgamma.(log.(1 .- Pgamma), 2, 5, false, true))
allEq(Rgeom, qgeom.(log.(1 .- Pgeom), pi/16, false, true))
allEq(Rhyper, qhyper.(log.(1 .- Phyper), 40, 30, 20, false, true))
allEq(Rlnorm, qlnorm.(log.(1 .- Plnorm), -1, 3, false, true))
allEq(Rlogis, qlogis.(log.(1 .- Plogis), 12, 2, false, true))
allEq(Rnbinom, qnbinom.(log.(1 .- Pnbinom), 7, .01, false, true))
allEq(Rnorm, qnorm.(log.(1 .- Pnorm), -1, 3, false, true))
allEq(Rpois, qpois.(log.(1 .- Ppois), 12, false, true))
allEq(Rsignrank, qsignrank.(log.(1 .- Psignrank), 47, false, true))
allEq(Rt, qt.(log.(1 .- Pt ), 11, false, true))
allEq(Rt2, qt.(log.(1 .- Pt2), 1.01, false, true), 1e-2)
allEq(Runif, qunif.(log.(1 .- Punif), .2, 2, false, true))
allEq(Rweibull, qweibull.(log.(1 .- Pweibull), 3, 2, false, true))
allEq(Rwilcox, qwilcox.(log.(1 .- Pwilcox), 13, 17, false, true))

## Test if srand working correctly
srand(124)
Expand Down

0 comments on commit 136d37f

Please sign in to comment.