diff --git a/NAMESPACE b/NAMESPACE index b8b257dad..eddb3b86d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -323,6 +323,7 @@ export(assertRxUiPrediction) export(assertRxUiRandomOnIdOnly) export(assertRxUiSingleEndpoint) export(assertRxUiTransformNormal) +export(assertRxUnbounded) export(assertVariableExists) export(assertVariableName) export(assertVariableNew) @@ -571,10 +572,12 @@ export(swapMatListWithCube) export(testCompartmentExists) export(testExists) export(testRxLinCmt) +export(testRxUnbounded) export(testVariableExists) export(toTrialDuration) export(uppergamma) export(waiver) +export(warnRxBounded) export(write.template.server) export(write.template.ui) export(xlab) diff --git a/R/assert.R b/R/assert.R index 7a4dce949..63aa5f6ba 100644 --- a/R/assert.R +++ b/R/assert.R @@ -552,8 +552,8 @@ testExists <- function(ui, x) { return(is.finite(.t$upper) || is.finite(.t$lower)) } .err <- .errDistArgRanges[[.t$err]] - return (!identical(.t$upper, .err[1]) || - !identical(.t$lower, .err[2])) + return (!identical(.t$lower, .err[1]) || + !identical(.t$upper, .err[2])) }, logical(1), USE.NAMES=FALSE), .theta$name) } #' Test if the rxode2 model has any parameters with user defined boundaries @@ -569,13 +569,9 @@ testExists <- function(ui, x) { #' #' one.cmt <- function() { #' ini({ -#' ## You may label each parameter with a comment -#' tka <- 0.45 # Log Ka -#' tcl <- log(c(0, 2.7, 100)) # Log Cl -#' ## This works with interactive models -#' ## You may also label the preceding line with label("label text") -#' tv <- 3.45; label("log V") -#' ## the label("Label name") works with all models +#' tka <- 0.45; label("Ka") +#' tcl <- log(c(0, 2.7, 100)); label("Cl") +#' tv <- 3.45; label("V") #' eta.ka ~ 0.6 #' eta.cl ~ 0.3 #' eta.v ~ 0.1 @@ -587,28 +583,27 @@ testExists <- function(ui, x) { #' v <- exp(tv + eta.v) #' linCmt() ~ add(add.sd) #' }) -# } -#' -#' testRxBounded(one.cmt) +#' } #' -#' try(assertRxBounded(one.cmt)) +#' testRxUnbounded(one.cmt) #' -#' warnAssertRxBounded(one.cmt) +#' try(assertRxUnbounded(one.cmt)) #' -testRxBounded <- function(ui) { - any(.getRxBounded(ui)) +#' warnRxBounded(one.cmt) +testRxUnbounded <- function(ui) { + !any(.getRxBounded(ui)) } -#' @describeIn testRxBounded Assert that the rxode2 model has any parameters with user defined boundaries +#' @describeIn testRxUnbounded Assert that the rxode2 model has any parameters with user defined boundaries #' @export -assertRxBounded <- function(ui, extra="", .var.name=.vname(ui)) { - if (testRxBounded(ui,extra=extra, .var.name=.var.name)) { +assertRxUnbounded <- function(ui, extra="", .var.name=.vname(ui)) { + if (testRxUnbounded(ui)) { return(invisible(ui)) } stop("'", .var.name, "' can not have user defined boundaries", extra, call.=FALSE) } -#' @describeIn testRxBounded Warn that the rxode2 model has any parameters with user defined boundaries +#' @describeIn testRxUnbounded Warn that the rxode2 model has any parameters with user defined boundaries #' @export warnRxBounded <- function(ui, extra="", .var.name=.vname(ui)) { .bound <- .getRxBounded(ui, extra=extra, .var.name=.var.name) diff --git a/man/assertCompartmentExists.Rd b/man/assertCompartmentExists.Rd index e7e1169ab..2b570facb 100644 --- a/man/assertCompartmentExists.Rd +++ b/man/assertCompartmentExists.Rd @@ -32,7 +32,8 @@ Other Assertions: \code{\link{assertCompartmentNew}()}, \code{\link{assertRxUi}()}, \code{\link{assertVariableExists}()}, -\code{\link{assertVariableNew}()} +\code{\link{assertVariableNew}()}, +\code{\link{testRxUnbounded}()} } \author{ Matthew Fidler & Bill Denney diff --git a/man/assertCompartmentName.Rd b/man/assertCompartmentName.Rd index 07f189c39..d6e121f73 100644 --- a/man/assertCompartmentName.Rd +++ b/man/assertCompartmentName.Rd @@ -48,7 +48,8 @@ Other Assertions: \code{\link{assertCompartmentNew}()}, \code{\link{assertRxUi}()}, \code{\link{assertVariableExists}()}, -\code{\link{assertVariableNew}()} +\code{\link{assertVariableNew}()}, +\code{\link{testRxUnbounded}()} } \author{ Bill Denney diff --git a/man/assertCompartmentNew.Rd b/man/assertCompartmentNew.Rd index 4ef97fb3b..e62fa9703 100644 --- a/man/assertCompartmentNew.Rd +++ b/man/assertCompartmentNew.Rd @@ -23,7 +23,8 @@ Other Assertions: \code{\link{assertCompartmentName}()}, \code{\link{assertRxUi}()}, \code{\link{assertVariableExists}()}, -\code{\link{assertVariableNew}()} +\code{\link{assertVariableNew}()}, +\code{\link{testRxUnbounded}()} } \author{ Matthew Fidler & Bill Denney diff --git a/man/assertRxUi.Rd b/man/assertRxUi.Rd index e422d7efa..ee4d4e725 100644 --- a/man/assertRxUi.Rd +++ b/man/assertRxUi.Rd @@ -102,7 +102,8 @@ Other Assertions: \code{\link{assertCompartmentName}()}, \code{\link{assertCompartmentNew}()}, \code{\link{assertVariableExists}()}, -\code{\link{assertVariableNew}()} +\code{\link{assertVariableNew}()}, +\code{\link{testRxUnbounded}()} } \author{ Matthew L. Fidler diff --git a/man/assertVariableExists.Rd b/man/assertVariableExists.Rd index f6a4c949b..2f657e098 100644 --- a/man/assertVariableExists.Rd +++ b/man/assertVariableExists.Rd @@ -34,7 +34,8 @@ Other Assertions: \code{\link{assertCompartmentName}()}, \code{\link{assertCompartmentNew}()}, \code{\link{assertRxUi}()}, -\code{\link{assertVariableNew}()} +\code{\link{assertVariableNew}()}, +\code{\link{testRxUnbounded}()} } \author{ Matthew L. Fidler diff --git a/man/assertVariableNew.Rd b/man/assertVariableNew.Rd index 5167180de..b596b60e5 100644 --- a/man/assertVariableNew.Rd +++ b/man/assertVariableNew.Rd @@ -23,7 +23,8 @@ Other Assertions: \code{\link{assertCompartmentName}()}, \code{\link{assertCompartmentNew}()}, \code{\link{assertRxUi}()}, -\code{\link{assertVariableExists}()} +\code{\link{assertVariableExists}()}, +\code{\link{testRxUnbounded}()} } \author{ Matthew L. Fidler diff --git a/man/reexports.Rd b/man/reexports.Rd index 2857ff16d..8cba3d62e 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -38,4 +38,3 @@ below to see their documentation. \item{magrittr}{\code{\link[magrittr:pipe]{\%>\%}}} }} -\value{ Inherited from parent routine } diff --git a/man/rxode2.Rd b/man/rxode2.Rd index af364b4f2..7477fbdb7 100644 --- a/man/rxode2.Rd +++ b/man/rxode2.Rd @@ -333,7 +333,7 @@ compilation model. \if{html}{\out{
}}\preformatted{## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ -## rxode2 2.1.3.9000 model named rx_f0354f9c2871ad18f2498f9a38405373 model (ready). +## rxode2 2.1.3.9000 model named rx_8f661799cf47f5449921e8fbac648362 model (ready). ## x$state: depot, center ## x$stateExtra: cp ## x$params: tka, tcl, tv, add.sd, eta.ka, eta.cl, eta.v, rxerr.cp @@ -346,7 +346,7 @@ mod$simulationIniModel \if{html}{\out{
}}\preformatted{## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ -## rxode2 2.1.3.9000 model named rx_c7662da228e359bf543bec87fc5e25c9 model (ready). +## rxode2 2.1.3.9000 model named rx_47bb7e55dc9a095ff1e536140b73b93e model (ready). ## x$state: depot, center ## x$stateExtra: cp ## x$params: tka, tcl, tv, add.sd, eta.ka, eta.cl, eta.v, rxerr.cp diff --git a/tests/testthat/test-assert.R b/tests/testthat/test-assert.R index 96c66bcbb..5a497de93 100644 --- a/tests/testthat/test-assert.R +++ b/tests/testthat/test-assert.R @@ -1,5 +1,31 @@ if (!.Call(`_rxode2_isIntel`)) { - test_that("assert or testRxLinCmt", { + + test_that("no warnings/errors without boundaries", { + + one.cmt <- function() { + ini({ + tka <- 0.45; label("Ka") + tcl <- log(2.7); label("Cl") + tv <- 3.45; label("V") + eta.ka ~ 0.6 + eta.cl ~ 0.3 + eta.v ~ 0.1 + add.sd <- 0.7 + }) + model({ + ka <- exp(tka + eta.ka) + cl <- exp(tcl + eta.cl) + v <- exp(tv + eta.v) + linCmt() ~ add(add.sd) + }) + } + + expect_true(testRxUnbounded(one.cmt)) + expect_error(assertRxUnbounded(one.cmt), NA) + expect_warning(warnRxBounded(one.cmt), NA) + }) + test_that("assert or testRxLinCmt and boundaries", { + one.cmt <- function() { ini({ tka <- 0.45; label("Ka") @@ -18,6 +44,10 @@ if (!.Call(`_rxode2_isIntel`)) { }) } + expect_false(testRxUnbounded(one.cmt)) + expect_error(assertRxUnbounded(one.cmt)) + expect_warning(warnRxBounded(one.cmt)) + expect_error(assertRxLinCmt(one.cmt), NA) expect_true(testRxLinCmt(one.cmt))