diff --git a/man/reexports.Rd b/man/reexports.Rd index 8cba3d62e..2857ff16d 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -38,3 +38,4 @@ below to see their documentation. \item{magrittr}{\code{\link[magrittr:pipe]{\%>\%}}} }} +\value{ Inherited from parent routine } diff --git a/src/genModelVars.h b/src/genModelVars.h index e44a90bb8..2395c2634 100644 --- a/src/genModelVars.h +++ b/src/genModelVars.h @@ -227,6 +227,9 @@ static inline int sortStateVectorsErrHandle(int prop, int pass, int i) { static inline SEXP sortStateVectors(SEXP ordS) { int *ord = INTEGER(ordS); + for (int i = 0; i < Rf_length(ordS); i++) { + ord[i] = 0; // explicitly initialize to avoid valgrind warning + } sbt.o = 0; // we can use sbt.o since all the code has already been output sbt.s[0] = 0; for (int i = 0; i < tb.de.n; i++) { diff --git a/tests/testthat/test-000-modelVars.R b/tests/testthat/test-000-modelVars.R index c2fa41864..bdb8e078e 100644 --- a/tests/testthat/test-000-modelVars.R +++ b/tests/testthat/test-000-modelVars.R @@ -20,6 +20,7 @@ d/dt(y3) = a3*y1*y2 et <- eventTable() et$add.sampling(seq(0, 20, by = 0.01)) + out <- solve(rigid, et) expect_equal(rxModelVars(rigid), rxModelVars(rigid$cmpMgr$rxDll())) diff --git a/tests/testthat/test-phi.R b/tests/testthat/test-phi.R index ea40e15c7..ce8c85591 100644 --- a/tests/testthat/test-phi.R +++ b/tests/testthat/test-phi.R @@ -1,106 +1,104 @@ rxTest({ - rxTest({ - test_that("phi/pnorm/qnorm", { - expect_equal(phi(1:3), pnorm(1:3)) - expect_equal(phi(as.double(1:3)), pnorm(as.double(1:3))) - - o <- rxode2({ - o <- phi(a) - }) - - expect_equal( - rxSolve(o, data.frame(a = 1:3), et(0))$o, - pnorm(as.double(1:3)) - ) - - o <- rxode2({ - o <- pnorm(a) - }) - - expect_equal( - rxSolve(o, data.frame(a = 1:3), et(0))$o, - pnorm(as.double(1:3)) - ) - - o <- rxode2({ - o <- pnorm(a, 0.5) - }) - - expect_equal( - rxSolve(o, data.frame(a = 1:3), et(0))$o, - pnorm(as.double(1:3), 0.5) - ) - - o <- rxode2({ - o <- pnorm(a, 0.5, 2) - }) - - expect_equal( - rxSolve(o, data.frame(a = 1:3), et(0))$o, - pnorm(as.double(1:3), 0.5, 2) - ) - - suppressMessages(expect_error(rxode2({ - o <- pnorm() - }))) - - suppressMessages(expect_error(rxode2({ - o <- pnorm(a, b, c, d) - }))) - - o <- rxode2({ - o <- qnorm(a) - }) - - expect_equal( - rxSolve(o, data.frame(a = 1:3), et(0))$o, - suppressWarnings(qnorm(as.double(1:3))) - ) - - o <- rxode2({ - o <- qnorm(a, 0.5) - }) - - expect_equal( - rxSolve(o, data.frame(a = 1:3), et(0))$o, - suppressWarnings(qnorm(as.double(1:3), 0.5)) - ) - - o <- rxode2({ - o <- qnorm(a, 0.5, 2) - }) - - expect_equal( - rxSolve(o, data.frame(a = 1:3), et(0))$o, - suppressWarnings(qnorm(as.double(1:3), 0.5, 2)) - ) - - suppressMessages(expect_error(rxode2({ - o <- qnorm() - }))) - - suppressMessages(expect_error(rxode2({ - o <- qnorm(a, b, c, d) - }))) - - m <- rxode2({ - o <- pnorm(a) - }) - - skip_if_not_installed("units") - expect_error(rxS(m), NA) - - m <- rxode2({ - o <- pnorm(a, b) - }) - - expect_error(rxS(m), NA) - - m <- rxode2({ - o <- pnorm(a, b, c) - }) - - expect_error(rxS(m), NA) + test_that("phi/pnorm/qnorm", { + expect_equal(phi(1:3), pnorm(1:3)) + expect_equal(phi(as.double(1:3)), pnorm(as.double(1:3))) + + o <- rxode2({ + o <- phi(a) }) + + expect_equal( + rxSolve(o, data.frame(a = 1:3), et(0))$o, + pnorm(as.double(1:3)) + ) + + o <- rxode2({ + o <- pnorm(a) + }) + + expect_equal( + rxSolve(o, data.frame(a = 1:3), et(0))$o, + pnorm(as.double(1:3)) + ) + + o <- rxode2({ + o <- pnorm(a, 0.5) + }) + + expect_equal( + rxSolve(o, data.frame(a = 1:3), et(0))$o, + pnorm(as.double(1:3), 0.5) + ) + + o <- rxode2({ + o <- pnorm(a, 0.5, 2) + }) + + expect_equal( + rxSolve(o, data.frame(a = 1:3), et(0))$o, + pnorm(as.double(1:3), 0.5, 2) + ) + + suppressMessages(expect_error(rxode2({ + o <- pnorm() + }))) + + suppressMessages(expect_error(rxode2({ + o <- pnorm(a, b, c, d) + }))) + + o <- rxode2({ + o <- qnorm(a) + }) + + expect_equal( + rxSolve(o, data.frame(a = 1:3), et(0))$o, + suppressWarnings(qnorm(as.double(1:3))) + ) + + o <- rxode2({ + o <- qnorm(a, 0.5) + }) + + expect_equal( + rxSolve(o, data.frame(a = 1:3), et(0))$o, + suppressWarnings(qnorm(as.double(1:3), 0.5)) + ) + + o <- rxode2({ + o <- qnorm(a, 0.5, 2) + }) + + expect_equal( + rxSolve(o, data.frame(a = 1:3), et(0))$o, + suppressWarnings(qnorm(as.double(1:3), 0.5, 2)) + ) + + suppressMessages(expect_error(rxode2({ + o <- qnorm() + }))) + + suppressMessages(expect_error(rxode2({ + o <- qnorm(a, b, c, d) + }))) + + m <- rxode2({ + o <- pnorm(a) + }) + + skip_if_not_installed("units") + expect_error(rxS(m), NA) + + m <- rxode2({ + o <- pnorm(a, b) + }) + + expect_error(rxS(m), NA) + + m <- rxode2({ + o <- pnorm(a, b, c) + }) + + expect_error(rxS(m), NA) }) })