Skip to content

Commit

Permalink
Add ignore to content
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Nov 28, 2024
1 parent 407d279 commit 2b0a3da
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
2 changes: 2 additions & 0 deletions R/content.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
cont=.monolix2rx$contLst,
cat=.monolix2rx$catLst2,
reg=.monolix2rx$regLst,
ignore=.monolix2rx$ignoreLst,
nbdoses=.monolix2rx$ssNbdoses,
yname=.monolix2rx$yname,
ynameQuote=.monolix2rx$ynameQuote,
Expand Down Expand Up @@ -186,6 +187,7 @@ as.character.monolix2rxContent <- function(x, ...) {
}, character(1), USE.NAMES = FALSE)
c(.cur[!is.na(.cur)],
.asCharacterReg(x),
.asCharacterIgnore(x),
vapply(x$cont, function(n) {
paste0(n, " = {use=covariate, type=continuous}")
}, character(1), USE.NAMES = FALSE),
Expand Down
6 changes: 3 additions & 3 deletions R/ind.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
#' @noRd
#' @author Matthew L. Fidler
.indIgnore <- function(ignore) {
.monolix2rx$ignoreLst <- c(.monolix2rx$ignoreLst, reg)
.monolix2rx$ignoreLst <- c(.monolix2rx$ignoreLst, ignore)
}

#' As.character for regressor items
Expand All @@ -141,8 +141,8 @@
#' @return character vector representing ignored variables
#' @author Matthew L. Fidler
.asCharacterIgnore <- function(x) {
if (length(x$ignoreLst) == 0L) return(character(0))
vapply(x$ignoreLst,
if (length(x$ignore) == 0L) return(character(0))
vapply(x$ignore,
function(n) {
paste0(n, " = {use = ignoredline}")
}, character(1), USE.NAMES = FALSE)
Expand Down
2 changes: 2 additions & 0 deletions src/mlxtranContent.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ extern sbuf curLine;
int individual_process_catCov(const char *name, D_ParseNode *pn, int i);
int individual_process_catId(const char *name, D_ParseNode *pn);
int individual_process_regressor(const char *name, D_ParseNode *pn);
int individual_process_ignore(const char *name, D_ParseNode *pn);

int content_process_identifier(const char *name, D_ParseNode *pn) {
if (!strcmp(name, "idLine")) {
Expand Down Expand Up @@ -318,6 +319,7 @@ void wprint_parsetree_content(D_ParserTables pt, D_ParseNode *pn, int depth, pri
int nch = d_get_number_of_children(pn);
if (individual_process_catId(name, pn) ||
individual_process_regressor(name, pn) ||
individual_process_ignore(name, pn) ||
content_process_identifier(name, pn) ||
content_process_time(name, pn) ||
content_process_evid(name, pn) ||
Expand Down
3 changes: 2 additions & 1 deletion src/mlxtranInd.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ void wprint_parsetree_individual(D_ParserTables pt, D_ParseNode *pn, int depth,
return;
} else if (individual_process_catId(name, pn) ||
individual_process_inpId(name, pn) ||
individual_process_regressor(name, pn)) {
individual_process_regressor(name, pn) ||
individual_process_ignore(name, pn)) {
// return early; no need to process more
return;
}
Expand Down
19 changes: 19 additions & 0 deletions tests/testthat/test-content.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,22 @@ test_that("dur", {
expect_equal(as.character(.content("dur = {use=infusiontime}")),
"dur = {use=infusiontime}")
})

test_that("content ignore", {

tmp <- .content("ID = {use=identifier}
TIME = {use=time}
EVID = {use=eventidentifier}
AMT = {use=amount}
DV = {use=observation, name={y1, y2}, yname={'1', '2'}, type={continuous, event}}
ADM = {use=administration}
YTYPE = {use=observationtype}
WT={use=covariate, type=continuous}
CRCL={use=covariate, type=continuous}
E0 = {use = regressor}
Emax = {use = regressor}
Race = {type=categorical, categories={Caucasian, Black, Latin}}
Sex = {type=categorical, categories={M, F}}
FLAG = {use=ignoredline}")

})

0 comments on commit 2b0a3da

Please sign in to comment.