From 7d902d7d575b13ec5b5cb34dc2588f0f5e25e8c2 Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Wed, 29 Nov 2023 16:29:21 -0600 Subject: [PATCH] Add lotri expressions into function and add to news --- NEWS.md | 12 ++++++++++++ R/rxUiGet.R | 17 ++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 8b75fdd5b..44f29b31b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -122,6 +122,18 @@ mu-referencing style to run the optimization. `plot(ci, Cc)` which will only plot the variable `Cc` that you summarized even if you also summarized `eff` (for instance). +- When the rxode2 ui is a compressed ui object, you can modify the ini + block with `$ini <-` or modify the model block with `$model <-`. + These are equivalent to `ini(model) <-` and `model(model) <-`, + respectively. Otherwise, the object is added to the user defined + components in the function (ie `$meta`). When the object is + uncompressed, it simply assigns it to the environment instead (just + like before). + +- When printing meta information that happens to be a `lotri` + compatible matrix, use `lotri` to express it instead of the default + R expression. + ## Internal new features - Add `as.model()` for list expressions, which implies `model(ui) <- diff --git a/R/rxUiGet.R b/R/rxUiGet.R index af43f75cd..0ee1149d2 100644 --- a/R/rxUiGet.R +++ b/R/rxUiGet.R @@ -185,7 +185,22 @@ rxUiGet.funPrint <- function(x, ...) { .ret <- vector("list", length(.ls) + ifelse(.hasIni, 3, 2)) .ret[[1]] <- quote(`{`) for (.i in seq_along(.ls)) { - .ret[[.i + 1]] <- eval(parse(text=paste("quote(", .ls[.i], "<-", deparse1(.x$meta[[.ls[.i]]]), ")"))) + .var <- .ls[.i] + .val <- .x$meta[[.ls[.i]]] + .isLotri <- FALSE + if (checkmate::checkMatrix(.val, any.missing=FALSE, row.names="strict", col.names="strict")) { + .dn <- dimnames(.val) + if (identical(.dn[[1]], .dn[[2]]) && isSymmetric(.val)) { + class(.val) <- c("lotriFix", class(.val)) + .val <- as.expression(.val) + .val <- bquote(.(str2lang(.var)) <- .(.val)) + .ret[[.i + 1]] <- .val + .isLotri <- TRUE + } + } + if (!.isLotri){ + .ret[[.i + 1]] <- eval(parse(text=paste("quote(", .var, "<-", deparse1(.val), ")"))) + } } .theta <- x$theta .omega <- x$omega