From 86ffe384f3a954d86cbd02f2603305591b5c7332 Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Tue, 5 Dec 2023 12:47:04 -0600 Subject: [PATCH 1/6] .iniGetAppendArg to start aligning ini() and model() --- NAMESPACE | 1 + R/piping-ini.R | 51 +++++++++++++++++++++++++++++-- data/rxReservedKeywords.rda | Bin 735 -> 733 bytes data/rxResidualError.rda | Bin 1694 -> 1694 bytes data/rxSyntaxFunctions.rda | Bin 2439 -> 2446 bytes man/dot-iniGetAppendArg.Rd | 26 ++++++++++++++++ man/rxode2.Rd | 14 +++++++-- tests/testthat/test-piping-ini.R | 13 +++++++- 8 files changed, 100 insertions(+), 5 deletions(-) create mode 100644 man/dot-iniGetAppendArg.Rd diff --git a/NAMESPACE b/NAMESPACE index 639ef73f2..a3797a01b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -197,6 +197,7 @@ export(.copyUi) export(.expandPars) export(.getLastIdLvl) export(.handleSingleErrTypeNormOrTFoceiBase) +export(.iniGetAppendArg) export(.iniHandleFixOrUnfix) export(.iniHandleLine) export(.malert) diff --git a/R/piping-ini.R b/R/piping-ini.R index b923908b8..283576ade 100644 --- a/R/piping-ini.R +++ b/R/piping-ini.R @@ -369,7 +369,8 @@ checkmate::assert_choice(append, choices = ini$name) appendClean <- which(ini$name == append) } else { - stop("'append' must be NULL, logical, numeric, or character", call. = FALSE) + stop("'append' must be NULL, logical, numeric, or character/expression of variable in model", + call. = FALSE) } lhs <- as.character(expr[[2]]) @@ -667,16 +668,59 @@ } expr } +#' This gets the append arg for the ini({}) piping +#' +#' @param f this is the `try(force(append))` argument, +#' @param s this is the `as.character(substitute(append))` argument +#' @return corrected ini piping argument +#' +#' This is exported for creating new ini methods that have the same +#' requirements for piping +#' +#' @export +#' @author Matthew L. Fidler +#' @keywords internal +.iniGetAppendArg <- function(f, s) { + if (inherits(f, "try-error") && + checkmate::testCharacter(s, len=1, any.missing=FALSE, + pattern="^[.]*[a-zA-Z]+[a-zA-Z0-9._]*$", + min.chars = 1)) { + return(s) + } + if (is.null(f)) { + return(NULL) + } else if (checkmate::testCharacter(f, len=1, any.missing=FALSE, + pattern="^[.]*[a-zA-Z]+[a-zA-Z0-9._]*$", + min.chars = 1)) { + return(f) + } else if (is.infinite(f)) { + return(f) + } else if (checkmate::testIntegerish(f, len=1, any.missing=FALSE)) { + if (f < 0) { + stop("'append' cannot be a negative integer", call.=FALSE) + } + return(f) + } else if (checkmate::testLogical(f, len=1)) { + # NA for model piping prepends + if (is.na(f)) return(FALSE) + return(f) + } + stop("'append' must be NULL, logical, numeric, or character/expression of variable in model", + call.=FALSE) +} #' @export #' @rdname ini ini.rxUi <- function(x, ..., envir=parent.frame(), append = NULL) { + .s <- as.character(substitute(append)) + .f <- try(force(append), silent=TRUE) + append <- .iniGetAppendArg(.f, .s) .ret <- rxUiDecompress(.copyUi(x)) # copy so (as expected) old UI isn't affected by the call .iniDf <- .ret$iniDf .iniLines <- .quoteCallInfoLines(match.call(expand.dots = TRUE)[-(1:2)], envir=envir, iniDf= .iniDf) if (length(.iniLines) == 0L) return(.ret$iniFun) lapply(.iniLines, function(line) { - .iniHandleLine(expr = line, rxui = .ret, envir = envir, append = append) + .iniHandleLine(expr = line, rxui = .ret, envir = envir, append=append) }) if (inherits(x, "rxUi")) { .x <- rxUiDecompress(x) @@ -695,6 +739,9 @@ ini.rxUi <- function(x, ..., envir=parent.frame(), append = NULL) { #' @rdname ini #' @export ini.default <- function(x, ..., envir=parent.frame(), append = NULL) { + .s <- as.character(substitute(append)) + .f <- try(force(append), silent=TRUE) + append <- .iniGetAppendArg(.f, .s) .ret <- try(as.rxUi(x), silent = TRUE) if (inherits(.ret, "try-error")) { stop("cannot figure out what to do with the ini({}) function", call.=FALSE) diff --git a/data/rxReservedKeywords.rda b/data/rxReservedKeywords.rda index 310c21c71569c2828be7b511ca538d5f198f14e8..80fc13cd1332ee7e68cacfe73ae72df8290d41e0 100644 GIT binary patch delta 716 zcmV;-0yF*J1>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jxoIPe8g%CxIl~$iXpvzi>!UF_>qS1R8c(fl!0nPy?3aCV&1Mi-; zKy#TAh%uN=LCT=CV0zHioI8LuDHn4eXYUHUX<|>Y_ZLpsj fN+dA#tNg6)B?+C~e1SL?XZX94DZ+$;+A1bc_P0BI diff --git a/data/rxResidualError.rda b/data/rxResidualError.rda index 59ed83c8c66facf925534c93ee0c5e161e54bd54..df63ee3a545fc8c80bccc0a63ba373a7c2eec0b2 100644 GIT binary patch delta 1685 zcmV;G25R}94W11SLRx4!F+o`-Q&~Z0Nneo;9)AEmN(luRo>0(a z4G$FZBTR$T$PEKP8Z-uhp`oC9M#6yJsBi!c01W_W007a502%-Q000^QML%j(fB};r z02&P%00Te(05kvq001RFRHY=*7zwou000nR00009h`})!001JSQhG9&Oan=@6B9-N zHGdffnWibU5u;215#&SEG-3rQLI@|J0256oskEA&Q`Ge|^%E%t=F1~Iyq?ErwkF?;i9B`c%vT|`*QeqN>#mocgy?wVNcPDbaZoSkq*2|=tc77 zO#K_Li5QK3d*kNVwg0~k?bqt7b(Y%>H-GL%$m4@=)5o8#e4K^#!quR(3zuu2w`s*4 zH;49fjt9An?B&inhP(HTbgeotHg$E>OwjAzG$!jP%Rt~bjYDS+RR8|XjvsqQIsL5-?dv2mWK0H41ckh zh=_{fxpx+2##ND&Sy@GmL~rhIc{fzwnVFeoh6Ixk0_Jk^<1;u_7ExJpw?F_10009s zBNH+$<B1V)WX zHmc>>Wzc43bo}?*(Q+`0Fk(zFuz!joHkWw z+D(;tqCQT?b!qzfce78irgm>e*p4lbsOH`pgqgI#IvFMcV0LjPLUv3iPLS>fMXPw- z<8rv&wZnzGwW8se<7phVok=FXG!6RU9RxT@$P0C4MPUQl5PdC+P7Nennt06ec|ajgm3M?x5vWt@x#Bz zyPd4f)tf4`-PN+n(|1?WB21AH2_%w9B$69$?Z###Mr4e}Wmv{zGPh5I zT@3=*FMkSYw$oijl`vQ>y!sT^cJAIv>C`Tq0NGXv(klff2#_hkwwn@4(1{Q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s zq7(tmj)D6xOABqWvW9SNe0VsO3IPltalpqWt18PWaVQQ+iqH0fpo$C*whf>w&GFs^ z<)BT2KR<_#VYr}Fkb?hCZ@aS+aVfF#Is&mZ32PO}5FLqn*}nv2!5v`eFksIIAe#Bz zS}$H)QRlWD55WPo9AoNBlxukC~5s}n18(2QaNdh3~ z4b1L9bqys5H#9;X0ju4$1oEmI73UNHK7MF7Tjzya5`$k8k-z z%5nHEvpiC$U?f1ntg}mMNnxnlCcUFQ>fpR!Z9y!NkbQqzA$&P+-M?&4E%7@}FVD(7 z8qRKNJ#3n=Y3w&Y#WSR8j5%3@9mJ-rIEDm*+e^k^$K=RN96Axiw?HY96|^r2^01bQ z(}U&z&~Q24GFUOry%-o4Cz%Cw3$_6wLq^3mG%>a}=9q%RPw$MUhnpxGZODm@DHskr zX}p}^gl2za(cJ7Nm7XTH1~*9uvF76}lB0@S4lo^)K`+e+e| z$I&m-#_*B^Z*i=}M3T7Y;FJQ?0MQ9FzO4(}} + +\if{html}{\out{
}}\preformatted{## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ +}\if{html}{\out{
}} \itemize{ \item Inside a \code{rxode2("")} string statement: }\if{html}{\out{ @@ -247,6 +250,9 @@ mod <- rxode2(\{ d/dt(centr) <- F*KA*depot - CL*C2 - Q*C2 + Q*C3; ") }\if{html}{\out{}} + +\if{html}{\out{
}}\preformatted{## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ +}\if{html}{\out{
}} \itemize{ \item In a file name to be loaded by rxode2: }\if{html}{\out{ @@ -325,7 +331,9 @@ compilation model. \if{html}{\out{
}}\preformatted{mod$simulationModel }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## rxode2 2.0.14.9000 model named rx_9140ece6c151a5d4341598adc0f7f3b6 model (ready). +\if{html}{\out{
}}\preformatted{## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ + +## rxode2 2.0.14.9000 model named rx_85848c9248e14e8cbf9a9b4a606b2010 model (ready). ## x$state: depot, center ## x$stateExtra: cp ## x$params: tka, tcl, tv, add.sd, eta.ka, eta.cl, eta.v, rxerr.cp @@ -336,7 +344,9 @@ compilation model. mod$simulationIniModel }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## rxode2 2.0.14.9000 model named rx_3696701c79e711bcf4b2c8ac921b3f65 model (ready). +\if{html}{\out{
}}\preformatted{## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ + +## rxode2 2.0.14.9000 model named rx_40b4a6f44b577c0e14f674ccc10f618e 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-piping-ini.R b/tests/testthat/test-piping-ini.R index b7f655d0a..a600133ea 100644 --- a/tests/testthat/test-piping-ini.R +++ b/tests/testthat/test-piping-ini.R @@ -145,6 +145,7 @@ test_that(".iniSimplifyAssignArrow", { }) test_that("piping with ini can update reorder parameters (rxode2/issues#352)", { + mod <- function() { ini({ a <- 1 @@ -157,7 +158,9 @@ test_that("piping with ini can update reorder parameters (rxode2/issues#352)", { b ~ add(addSd) }) } + ui <- rxode2(mod) + # No modification expect_equal(ui$iniDf$name, c("a", "b", "c", "addSd")) # b to the top by number @@ -170,6 +173,9 @@ test_that("piping with ini can update reorder parameters (rxode2/issues#352)", { expect_equal(suppressMessages(ini(ui, b <- 1, append = TRUE))$iniDf$name, c("a", "c", "addSd", "b")) # b to the bottom by name expect_equal(suppressMessages(ini(ui, b <- 1, append = "addSd"))$iniDf$name, c("a", "c", "addSd", "b")) + + expect_equal(suppressMessages(ini(ui, b <- 1, append = addSd))$iniDf$name, c("a", "c", "addSd", "b")) + # b after c expect_equal(suppressMessages(ini(ui, b <- 1, append = "c"))$iniDf$name, c("a", "c", "b", "addSd")) # a and b after c; counter-intuitive: the order of a and b are reversed @@ -180,11 +186,16 @@ test_that("piping with ini can update reorder parameters (rxode2/issues#352)", { regexp = "parameter 'b' set to be moved after itself, no change in order made" ) + expect_error( + ini(ui, b <- 1, append = d/dt(fun)), + "append") + # Invalid parameter is correctly caught expect_error( ini(ui, b <- 1, append = "foo"), "append" ) + }) test_that(".iniAddCovarianceBetweenTwoEtaValues", { @@ -277,7 +288,7 @@ test_that(".iniHandleAppend", { } expect_error( ini(mod, a <- 1, append=factor("A")), - regexp = "'append' must be NULL, logical, numeric, or character" + regexp = "'append' must be NULL, logical, numeric, or character/expression of variable in model" ) expect_error( ini(mod, q <- 1, append=0), From e18bec776a59534b4516c326da44b27b36aa9e12 Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Tue, 5 Dec 2023 14:02:08 -0600 Subject: [PATCH 2/6] align argument types with ini(append) --- R/piping-ini.R | 4 ++-- R/piping-model.R | 25 +++++++++++++++++++++---- R/piping.R | 2 +- man/dot-modelHandleModelLines.Rd | 2 +- man/model.Rd | 8 ++++---- man/reexports.Rd | 1 - man/rxode2.Rd | 14 ++------------ tests/testthat/test-piping-ini.R | 1 + 8 files changed, 32 insertions(+), 25 deletions(-) diff --git a/R/piping-ini.R b/R/piping-ini.R index 283576ade..f636d3add 100644 --- a/R/piping-ini.R +++ b/R/piping-ini.R @@ -690,8 +690,8 @@ if (is.null(f)) { return(NULL) } else if (checkmate::testCharacter(f, len=1, any.missing=FALSE, - pattern="^[.]*[a-zA-Z]+[a-zA-Z0-9._]*$", - min.chars = 1)) { + pattern="^[.]*[a-zA-Z]+[a-zA-Z0-9._]*$", + min.chars = 1)) { return(f) } else if (is.infinite(f)) { return(f) diff --git a/R/piping-model.R b/R/piping-model.R index df4f62812..b62c8ea5a 100644 --- a/R/piping-model.R +++ b/R/piping-model.R @@ -1,6 +1,6 @@ #' @export #' @rdname model -model.function <- function(x, ..., append=FALSE, auto=getOption("rxode2.autoVarPiping", TRUE), +model.function <- function(x, ..., append=NULL, auto=getOption("rxode2.autoVarPiping", TRUE), cov=NULL, envir=parent.frame()) { .modelLines <- .quoteCallInfoLines(match.call(expand.dots = TRUE)[-(1:2)], envir=envir) .ret <- rxUiDecompress(rxode2(x)) @@ -11,7 +11,7 @@ model.function <- function(x, ..., append=FALSE, auto=getOption("rxode2.autoVarP #' @export #' @rdname model -model.rxUi <- function(x, ..., append=FALSE, auto=getOption("rxode2.autoVarPiping", TRUE), +model.rxUi <- function(x, ..., append=NULL, auto=getOption("rxode2.autoVarPiping", TRUE), cov=NULL, envir=parent.frame()) { .modelLines <- .quoteCallInfoLines(match.call(expand.dots = TRUE)[-(1:2)], envir=envir) .ret <- rxUiDecompress(.copyUi(x)) # copy so (as expected) old UI isn't affected by the call @@ -32,7 +32,7 @@ model.rxUi <- function(x, ..., append=FALSE, auto=getOption("rxode2.autoVarPipin #' @export #' @rdname model -model.rxode2 <- function(x, ..., append=FALSE, auto=getOption("rxode2.autoVarPiping", TRUE), +model.rxode2 <- function(x, ..., append=NULL, auto=getOption("rxode2.autoVarPiping", TRUE), cov=NULL, envir=parent.frame()) { .modelLines <- .quoteCallInfoLines(match.call(expand.dots = TRUE)[-(1:2)], envir=envir) x <- as.function(x) @@ -56,7 +56,7 @@ model.rxModelVars <- model.rxode2 #' @return New UI #' @author Matthew L. Fidler #' @export -.modelHandleModelLines <- function(modelLines, rxui, modifyIni=FALSE, append=FALSE, +.modelHandleModelLines <- function(modelLines, rxui, modifyIni=FALSE, append=NULL, auto=getOption("rxode2.autoVarPiping", TRUE), cov=NULL, envir) { checkmate::assertLogical(modifyIni, any.missing=FALSE, len=1) @@ -68,6 +68,23 @@ model.rxModelVars <- model.rxode2 rxui <- rxUiDecompress(rxui) if (!is.null(.nsEnv$.quoteCallInfoLinesAppend)) { .ll <- length(rxui$lstExpr) + if (identical(.nsEnv$.quoteCallInfoLinesAppend, quote(Inf))) { + .nsEnv$.quoteCallInfoLinesAppend <- TRUE + } else if (identical(.nsEnv$.quoteCallInfoLinesAppend, quote(-Inf))) { + .nsEnv$.quoteCallInfoLinesAppend <- NA + } else if (identical(.nsEnv$.quoteCallInfoLinesAppend, quote(FALSE))) { + .nsEnv$.quoteCallInfoLinesAppend <- NA + } else if (identical(.nsEnv$.quoteCallInfoLinesAppend, quote(0))) { + .nsEnv$.quoteCallInfoLinesAppend <- NA + } else if (checkmate::testIntegerish(.nsEnv$.quoteCallInfoLinesAppend, lower=.ll)) { + .nsEnv$.quoteCallInfoLinesAppend <- TRUE + } else if (checkmate::testIntegerish(.nsEnv$.quoteCallInfoLinesAppend, lower=0, upper=.ll)) { + .nsEnv$.quoteCallInfoLinesAppend <- .getLhs(rxui$lstExpr[[.nsEnv$.quoteCallInfoLinesAppend]]) + } else if (checkmate::testCharacter(.nsEnv$.quoteCallInfoLinesAppend, len=1, any.missing=FALSE, + pattern="^[.]*[a-zA-Z]+[a-zA-Z0-9._]*$", + min.chars = 1)) { + .nsEnv$.quoteCallInfoLinesAppend <- str2lang(.nsEnv$.quoteCallInfoLinesAppend) + } .w <- which(vapply(seq_len(.ll), function(i) { .lhs <- .getLhs(rxui$lstExpr[[i]]) diff --git a/R/piping.R b/R/piping.R index 93da808b6..b75984aeb 100644 --- a/R/piping.R +++ b/R/piping.R @@ -1,4 +1,4 @@ -#' This copies the rxode2 UI object so it can be modified +#' This copies the rxode2 UI object so it can be modified #' #' @param ui Original UI object #' @return Copied UI object diff --git a/man/dot-modelHandleModelLines.Rd b/man/dot-modelHandleModelLines.Rd index e9cb9b76b..a60da6ef4 100644 --- a/man/dot-modelHandleModelLines.Rd +++ b/man/dot-modelHandleModelLines.Rd @@ -8,7 +8,7 @@ modelLines, rxui, modifyIni = FALSE, - append = FALSE, + append = NULL, auto = getOption("rxode2.autoVarPiping", TRUE), cov = NULL, envir diff --git a/man/model.Rd b/man/model.Rd index 02f0ca563..bc081d0a9 100644 --- a/man/model.Rd +++ b/man/model.Rd @@ -12,7 +12,7 @@ \method{model}{`function`}( x, ..., - append = FALSE, + append = NULL, auto = getOption("rxode2.autoVarPiping", TRUE), cov = NULL, envir = parent.frame() @@ -21,7 +21,7 @@ \method{model}{rxUi}( x, ..., - append = FALSE, + append = NULL, auto = getOption("rxode2.autoVarPiping", TRUE), cov = NULL, envir = parent.frame() @@ -30,7 +30,7 @@ \method{model}{rxode2}( x, ..., - append = FALSE, + append = NULL, auto = getOption("rxode2.autoVarPiping", TRUE), cov = NULL, envir = parent.frame() @@ -39,7 +39,7 @@ \method{model}{rxModelVars}( x, ..., - append = FALSE, + append = NULL, auto = getOption("rxode2.autoVarPiping", TRUE), cov = NULL, envir = parent.frame() diff --git a/man/reexports.Rd b/man/reexports.Rd index 365c14ab7..f1310e9e9 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -82,4 +82,3 @@ below to see their documentation. \item{rxode2random}{\code{\link[rxode2random:dot-cbindOme]{.cbindOme}}, \code{\link[rxode2random:dot-expandPars]{.expandPars}}, \code{\link[rxode2random:dot-vecDf]{.vecDf}}, \code{\link[rxode2random]{cvPost}}, \code{\link[rxode2random]{invWR1d}}, \code{\link[rxode2random]{phi}}, \code{\link[rxode2random]{rinvchisq}}, \code{\link[rxode2random]{rLKJ1}}, \code{\link[rxode2random]{rxGetSeed}}, \code{\link[rxode2random]{rxGetSeed}}, \code{\link[rxode2random]{rxRmvn}}, \code{\link[rxode2random]{rxSeedEng}}, \code{\link[rxode2random]{rxSetSeed}}, \code{\link[rxode2random]{rxSetSeed}}, \code{\link[rxode2random]{rxSetSeed}}, \code{\link[rxode2random:rxWithSeed]{rxWithPreserveSeed}}, \code{\link[rxode2random]{rxWithSeed}}, \code{\link[rxode2random]{rxWithSeed}}} }} -\value{ Inherited from parent routine } diff --git a/man/rxode2.Rd b/man/rxode2.Rd index 9de61ca9a..43b14e371 100644 --- a/man/rxode2.Rd +++ b/man/rxode2.Rd @@ -232,9 +232,6 @@ mod <- rxode2(\{ d/dt(centr) <- F*KA*depot - CL*C2 - Q*C2 + Q*C3; \}) }\if{html}{\out{
}} - -\if{html}{\out{
}}\preformatted{## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ -}\if{html}{\out{
}} \itemize{ \item Inside a \code{rxode2("")} string statement: }\if{html}{\out{ @@ -250,9 +247,6 @@ mod <- rxode2(\{ d/dt(centr) <- F*KA*depot - CL*C2 - Q*C2 + Q*C3; ") }\if{html}{\out{
}} - -\if{html}{\out{
}}\preformatted{## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ -}\if{html}{\out{
}} \itemize{ \item In a file name to be loaded by rxode2: }\if{html}{\out{ @@ -331,9 +325,7 @@ compilation model. \if{html}{\out{
}}\preformatted{mod$simulationModel }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ - -## rxode2 2.0.14.9000 model named rx_85848c9248e14e8cbf9a9b4a606b2010 model (ready). +\if{html}{\out{
}}\preformatted{## rxode2 2.0.14.9000 model named rx_85848c9248e14e8cbf9a9b4a606b2010 model (ready). ## x$state: depot, center ## x$stateExtra: cp ## x$params: tka, tcl, tv, add.sd, eta.ka, eta.cl, eta.v, rxerr.cp @@ -344,9 +336,7 @@ compilation model. mod$simulationIniModel }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ - -## rxode2 2.0.14.9000 model named rx_40b4a6f44b577c0e14f674ccc10f618e model (ready). +\if{html}{\out{
}}\preformatted{## rxode2 2.0.14.9000 model named rx_40b4a6f44b577c0e14f674ccc10f618e 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-piping-ini.R b/tests/testthat/test-piping-ini.R index a600133ea..a0b63fedf 100644 --- a/tests/testthat/test-piping-ini.R +++ b/tests/testthat/test-piping-ini.R @@ -286,6 +286,7 @@ test_that(".iniHandleAppend", { b ~ add(addSd) }) } + expect_error( ini(mod, a <- 1, append=factor("A")), regexp = "'append' must be NULL, logical, numeric, or character/expression of variable in model" From 7eb86db122c7005ebbd7c370af7afa7cad34f95a Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Tue, 5 Dec 2023 14:45:04 -0600 Subject: [PATCH 3/6] Add some tests and fixes for appending models --- R/piping-model.R | 12 ++++---- tests/testthat/test-ui-piping.R | 51 +++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/R/piping-model.R b/R/piping-model.R index b62c8ea5a..ba41337ea 100644 --- a/R/piping-model.R +++ b/R/piping-model.R @@ -72,8 +72,6 @@ model.rxModelVars <- model.rxode2 .nsEnv$.quoteCallInfoLinesAppend <- TRUE } else if (identical(.nsEnv$.quoteCallInfoLinesAppend, quote(-Inf))) { .nsEnv$.quoteCallInfoLinesAppend <- NA - } else if (identical(.nsEnv$.quoteCallInfoLinesAppend, quote(FALSE))) { - .nsEnv$.quoteCallInfoLinesAppend <- NA } else if (identical(.nsEnv$.quoteCallInfoLinesAppend, quote(0))) { .nsEnv$.quoteCallInfoLinesAppend <- NA } else if (checkmate::testIntegerish(.nsEnv$.quoteCallInfoLinesAppend, lower=.ll)) { @@ -81,9 +79,13 @@ model.rxModelVars <- model.rxode2 } else if (checkmate::testIntegerish(.nsEnv$.quoteCallInfoLinesAppend, lower=0, upper=.ll)) { .nsEnv$.quoteCallInfoLinesAppend <- .getLhs(rxui$lstExpr[[.nsEnv$.quoteCallInfoLinesAppend]]) } else if (checkmate::testCharacter(.nsEnv$.quoteCallInfoLinesAppend, len=1, any.missing=FALSE, - pattern="^[.]*[a-zA-Z]+[a-zA-Z0-9._]*$", min.chars = 1)) { - .nsEnv$.quoteCallInfoLinesAppend <- str2lang(.nsEnv$.quoteCallInfoLinesAppend) + .tmp <- try(str2lang(.nsEnv$.quoteCallInfoLinesAppend), silent=TRUE) + if (inherits(.tmp, "try-error")) { + stop("'append' must refer to a model line when a character", + call. = FALSE) + } + .nsEnv$.quoteCallInfoLinesAppend <- .tmp } .w <- which(vapply(seq_len(.ll), function(i) { @@ -129,7 +131,7 @@ model.rxModelVars <- model.rxode2 envir=rxui) } .doAppend <- TRUE - } else if (is.logical(append) && length(append) == 1L && is.na(append)) { + } else if (is.logical(append) && length(append) == 1L && (is.na(append) || !append)) { assign("lstExpr", c(modelLines, rxui$lstExpr), envir=rxui) .doAppend <- TRUE } else if (isTRUE(append)) { diff --git a/tests/testthat/test-ui-piping.R b/tests/testthat/test-ui-piping.R index 2aac8fe55..24027b836 100644 --- a/tests/testthat/test-ui-piping.R +++ b/tests/testthat/test-ui-piping.R @@ -2037,6 +2037,17 @@ test_that("piping append", { expect_equal(mod5$theta, c(tka = 0.45, tcl = 1, tv = 3.45, add.sd = 0.7)) + mod5 <- mod |> + model({ + PD <- 1-emax*cp/(ec50+cp) + ## + effect(0) <- e0 + kin <- e0*kout + d/dt(effect) <- kin*PD -kout*effect + }, append="d/dt(center)") + + expect_equal(mod5$theta, c(tka = 0.45, tcl = 1, tv = 3.45, add.sd = 0.7)) + mod6 <- mod5 |> model({ emax <- exp(temax) @@ -2057,6 +2068,46 @@ test_that("piping append", { eta.e0 ~ 1 })) + mod6 <- mod5 |> + model({ + emax <- exp(temax) + e0 <- exp(te0 + eta.e0) + ec50 <- exp(tec50) + kin <- exp(tkin) + kout <- exp(tkout) + }, append=FALSE) + + expect_equal( + mod6$omega, + lotri({ + eta.cl ~ 0.3 + eta.v ~ 0.1 + eta.e0 ~ 1 + })) + + expect_equal(mod6$theta, + c(tka = 0.45, tcl = 1, tv = 3.45, add.sd = 0.7, temax = 1, te0 = 1, tec50 = 1, tkin = 1, tkout = 1)) + + mod6 <- mod5 |> + model({ + emax <- exp(temax) + e0 <- exp(te0 + eta.e0) + ec50 <- exp(tec50) + kin <- exp(tkin) + kout <- exp(tkout) + }, append=0) + + expect_equal( + mod6$omega, + lotri({ + eta.cl ~ 0.3 + eta.v ~ 0.1 + eta.e0 ~ 1 + })) + + expect_equal(mod6$theta, + c(tka = 0.45, tcl = 1, tv = 3.45, add.sd = 0.7, temax = 1, te0 = 1, tec50 = 1, tkin = 1, tkout = 1)) + # make sure auto model piping turns off withr::with_options(list(rxode2.autoVarPiping=FALSE), From 6083cb2ff6f0ef154c3d60a1306a95f0a23f1e38 Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Tue, 5 Dec 2023 14:56:02 -0600 Subject: [PATCH 4/6] Align/test behavior of append in `ini()` and `model()` piping --- R/piping-model.R | 21 ++++++++++++++------- tests/testthat/test-ui-piping.R | 12 ++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/R/piping-model.R b/R/piping-model.R index ba41337ea..c6633755f 100644 --- a/R/piping-model.R +++ b/R/piping-model.R @@ -66,23 +66,30 @@ model.rxModelVars <- model.rxode2 .varSelect$cov <- cov .doAppend <- FALSE rxui <- rxUiDecompress(rxui) + .ll <- length(rxui$lstExpr) if (!is.null(.nsEnv$.quoteCallInfoLinesAppend)) { - .ll <- length(rxui$lstExpr) if (identical(.nsEnv$.quoteCallInfoLinesAppend, quote(Inf))) { - .nsEnv$.quoteCallInfoLinesAppend <- TRUE + .nsEnv$.quoteCallInfoLinesAppend <- NULL + append <- TRUE } else if (identical(.nsEnv$.quoteCallInfoLinesAppend, quote(-Inf))) { - .nsEnv$.quoteCallInfoLinesAppend <- NA + .nsEnv$.quoteCallInfoLinesAppend <- NULL + append <- NA } else if (identical(.nsEnv$.quoteCallInfoLinesAppend, quote(0))) { - .nsEnv$.quoteCallInfoLinesAppend <- NA + .nsEnv$.quoteCallInfoLinesAppend <- NULL + append <- NA } else if (checkmate::testIntegerish(.nsEnv$.quoteCallInfoLinesAppend, lower=.ll)) { - .nsEnv$.quoteCallInfoLinesAppend <- TRUE - } else if (checkmate::testIntegerish(.nsEnv$.quoteCallInfoLinesAppend, lower=0, upper=.ll)) { + .nsEnv$.quoteCallInfoLinesAppend <- NULL + append <- TRUE + } + } + if (!is.null(.nsEnv$.quoteCallInfoLinesAppend)) { + if (checkmate::testIntegerish(.nsEnv$.quoteCallInfoLinesAppend, lower=0, upper=.ll)) { .nsEnv$.quoteCallInfoLinesAppend <- .getLhs(rxui$lstExpr[[.nsEnv$.quoteCallInfoLinesAppend]]) } else if (checkmate::testCharacter(.nsEnv$.quoteCallInfoLinesAppend, len=1, any.missing=FALSE, min.chars = 1)) { .tmp <- try(str2lang(.nsEnv$.quoteCallInfoLinesAppend), silent=TRUE) if (inherits(.tmp, "try-error")) { - stop("'append' must refer to a model line when a character", + stop("'append' must refer to a LHS model line when a character", call. = FALSE) } .nsEnv$.quoteCallInfoLinesAppend <- .tmp diff --git a/tests/testthat/test-ui-piping.R b/tests/testthat/test-ui-piping.R index 24027b836..0103e6420 100644 --- a/tests/testthat/test-ui-piping.R +++ b/tests/testthat/test-ui-piping.R @@ -1428,6 +1428,18 @@ rxTest({ expect_true("cp1" %in% f2$mv0$lhs) expect_equal(f2$lstExpr[[length(f2$lstExpr)]], quote(cp1 <- cp)) + f <- rxode2(ocmt) + f2 <- f %>% model(cp1 <- cp, append=Inf) + + expect_true("cp1" %in% f2$mv0$lhs) + expect_equal(f2$lstExpr[[length(f2$lstExpr)]], quote(cp1 <- cp)) + + f <- rxode2(ocmt) + f2 <- f %>% model(cp1 <- cp, append=100) + + expect_true("cp1" %in% f2$mv0$lhs) + expect_equal(f2$lstExpr[[length(f2$lstExpr)]], quote(cp1 <- cp)) + f2 <- f %>% model(f2 <- 3 * 2, append=NA) expect_true("f2" %in% f2$mv0$lhs) expect_equal(f2$lstExpr[[1]], quote(f2 <- 3 * 2)) From 7898ae92bcd78b5b2f7c2a3384287e8e546fed9a Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Tue, 5 Dec 2023 15:07:26 -0600 Subject: [PATCH 5/6] Add news about alignment --- NEWS.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/NEWS.md b/NEWS.md index f1e0fcde2..2b6947a23 100644 --- a/NEWS.md +++ b/NEWS.md @@ -150,6 +150,20 @@ mu-referencing style to run the optimization. be kept carrying more information with it (for example ordered factors, data frame columns with unit information, etc) +- Piping arguments `append` for `ini()` and `model()` have been + aligned to perform similarly. Therefore `ini(append=)` now can take + expressions instead of simply strings and `model(append=)` can also + take strings. Also model piping now can specify the integer line + number to be modified just like the `ini()` could. Also + `model(append=FALSE)` has been changed to `model(append=NULL)`. + While the behavior is the same when you don't specify the argument, + the behavior has changed to align with `ini()` when piping. Hence + `model(append=TRUE)` will append and `model(append=FALSE)` will now + pre-pend to the model. `model(append=NULL)` will modify lines like + the behavior of `ini(append=NULL)`. The default of `model(line)` + modifying a line in-place still applies. While this is a breaking + change, most code will perform the same. + ## Internal new features - Add `as.model()` for list expressions, which implies `model(ui) <- From 8ce15c478e6f5548567686cba7ae07554dcb63c8 Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Tue, 5 Dec 2023 15:40:28 -0600 Subject: [PATCH 6/6] Add call.=FALSE --- R/piping-ini.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/piping-ini.R b/R/piping-ini.R index f636d3add..ffa89fe51 100644 --- a/R/piping-ini.R +++ b/R/piping-ini.R @@ -331,7 +331,8 @@ if (length(.w) != 1) { stop("cannot find parameter '", lhs, "'", call.=FALSE) } else if (!is.character(newLabel) || !(length(newLabel) == 1)) { - stop("the new label for '", lhs, "' must be a character string") + stop("the new label for '", lhs, "' must be a character string", + call.=FALSE) } ini$label[.w] <- newLabel assign("iniDf", ini, envir=rxui)