Skip to content

Commit

Permalink
Fix tests in case with no fftw support
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Dec 21, 2015
1 parent 943a591 commit 729000c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion inst/tests/test-mcmc.R
Expand Up @@ -57,7 +57,7 @@ test_that("Likelihood function is saved with fit", {
samples <- mcmc(lik, c(0, 0), 10, 1, print.every=0)
expect_that(samples, has_attribute("func"))
expect_that(attr(samples, "func"), is_a("function"))
expect_that(attr(samples, "func"), is_identical_to(lik))
expect_that(attr(samples, "func"), equals(lik))

samples.no.func <- mcmc(lik, c(0, 0), 10, 1, print.every=0,
keep.func=FALSE)
Expand Down
12 changes: 6 additions & 6 deletions inst/tests/test-ode.R
Expand Up @@ -28,8 +28,8 @@ control.gslode.R <- check.control.ode(list(backend="gslode",
control.deSolve <- check.control.ode(list(backend="deSolve"))

## Run the calculations with deSolve's lsoda (no clever tricks)
res.ref <- lsoda(y, tt, derivs.for.deSolve(derivs), pars,
atol=control.deSolve$tol, rtol=control.deSolve$tol)
res.ref <- deSolve::lsoda(y, tt, derivs.for.deSolve(derivs), pars,
atol=control.deSolve$tol, rtol=control.deSolve$tol)
## Convert this to the format that we expect (drop time column and
## transpose data).
res.ref <- unname(t(res.ref[-1,-1,drop=FALSE]))
Expand Down Expand Up @@ -80,8 +80,8 @@ tm$set(pars.t)
## changes to tm.
derivs.t <- make.derivs.t(derivs, tm)

res.t.ref <- lsoda(y, tt, derivs.for.deSolve(derivs.t), pars,
atol=control.deSolve$tol, rtol=control.deSolve$tol)
res.t.ref <- deSolve::lsoda(y, tt, derivs.for.deSolve(derivs.t), pars,
atol=control.deSolve$tol, rtol=control.deSolve$tol)
res.t.ref <- unname(t(res.t.ref[-1,-1,drop=FALSE]))

## Quick check that this agrees with the original reference set, as
Expand Down Expand Up @@ -141,8 +141,8 @@ pars.t[c(2,4)] <- .01
tm$set(pars.t)

## Rerun the above code
res.t.ref <- lsoda(y, tt, derivs.for.deSolve(derivs.t), pars,
atol=control.deSolve$tol, rtol=control.deSolve$tol)
res.t.ref <- deSolve::lsoda(y, tt, derivs.for.deSolve(derivs.t), pars,
atol=control.deSolve$tol, rtol=control.deSolve$tol)
res.t.ref <- unname(t(res.t.ref[-1,-1,drop=FALSE]))

## Check that the reference example differs:
Expand Down
4 changes: 4 additions & 0 deletions inst/tests/test-quasse-internal.R
Expand Up @@ -65,6 +65,10 @@ for ( drift in c(0, .01) ) {
expect_that(pars.fft$lo[1:5], equals(pars.mol$lo[1:5]))
expect_that(pars.fft$lo[1:5], is_identical_to(pars.mol$lo[1:5]))

## Bail here if no FFTW support, even though we could do most of this.
if (!check.fftC(FALSE)) {
next
}
pde.fftC <- with(control.fft, make.pde.quasse.fftC(nx, dx, dt.max, 2L, flags))
pde.fftR <- with(control.fft, make.pde.quasse.fftR(nx, dx, dt.max, 2L))
pde.mol <- with(control.mol, make.pde.quasse.mol(ndat, dx, 2L, atol, rtol))
Expand Down
2 changes: 2 additions & 0 deletions inst/tests/test-quasse-split.R
Expand Up @@ -21,6 +21,7 @@ control.C.2 <- c(control.C.1, tips.combined=TRUE)
control.M.1 <- list(method="mol")
control.R.1 <- list(dt.max=1/200, method="fftR")

if (check.fftC(FALSE)) {
lik.s <- make.quasse.split(phy, phy$tip.state, sd, sigmoid.x,
constant.x, "nd5", Inf, control.C.1)
lik.q <- make.quasse(phy, phy$tip.state, sd, sigmoid.x, constant.x,
Expand All @@ -41,3 +42,4 @@ expect_that(lik.s(pars2.s), equals(ll.q))

pars3.s <- pars + runif(length(pars.s), 0, .05)
expect_that(lik.s(pars3.s), equals(-54.47383577050427))
}
2 changes: 2 additions & 0 deletions inst/tests/test-quasse.R
Expand Up @@ -20,6 +20,7 @@ control.C.2 <- c(control.C.1, tips.combined=TRUE)
control.M.1 <- list(method="mol")
control.R.1 <- list(dt.max=1/200, method="fftR")

if (check.fftC(FALSE)) {
lik.C.1 <- make.quasse(phy, phy$tip.state, sd, sigmoid.x, constant.x,
control.C.1)
##lik.C.2 <- make.quasse(phy, phy$tip.state, sd, sigmoid.x, constant.x,
Expand All @@ -45,3 +46,4 @@ expect_that(lik.C.1(pars, root=ROOT.GIVEN, root.f=root.f),
pars2 <- pars
pars2[6] <- 0.01
expect_that(lik.C.1(pars2), equals(-62.040165682569537))
}

0 comments on commit 729000c

Please sign in to comment.