Skip to content

Commit

Permalink
allow multiple PLUGIN
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebaron committed Sep 23, 2024
1 parent bb9c415 commit c933a69
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
3 changes: 1 addition & 2 deletions R/Aaaa.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ block_list <- c("ENV", "PROB", "PARAM", "INIT",
"PREAMBLE", "PRED", "BLOCK", "TRANSIT", "YAML", "NMEXT",
"INPUT")

block_list_single <- c("MAIN", "SET", "GLOBAL", "PREAMBLE", "PRED", "TABLE",
"ODE", "PKMODEL", "PLUGIN")
block_list_single <- c("MAIN", "SET", "GLOBAL", "PREAMBLE", "PRED", "PKMODEL")

Reserved_cvar <- c("SOLVERTIME","table","ETA","EPS", "AMT", "CMT",
"ID", "TIME", "EVID","simeps", "self", "simeta",
Expand Down
15 changes: 8 additions & 7 deletions R/modspec.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,16 @@ check_sim_eta_eps_n <- function(x, spec) {
}

check_spec_contents <- function(x, crump = TRUE, warn = TRUE, ...) {
invalid <- setdiff(x, block_list)
valid <- intersect(x, block_list)

check_duplicated <- intersect(block_list_single, x)
# Check for valid and invalid blocks
invalid <- base::setdiff(x, block_list)
valid <- base::intersect(x, block_list)

# Check for block duplicates where we only allow single
check_duplicated <- base::intersect(x, block_list_single)
dups <- c()
for(bl in check_duplicated) {
if(sum(bl == x) > 1) {
dups <- c(dups, bl)
for(block in check_duplicated) {
if(sum(block == x) > 1) {
dups <- c(dups, block)
}
}
if(length(dups)) {
Expand Down
11 changes: 8 additions & 3 deletions R/mread.R
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,12 @@ mread <- function(model, project = getOption("mrgsolve.project", getwd()),
# Collect potential multiples
subr <- collect_subr(spec)
table <- unlist(spec[names(spec)=="TABLE"], use.names = FALSE)
spec[["ODE"]] <- unlist(spec[names(spec)=="ODE"], use.names = FALSE)
if("ODE" %in% names(spec)) {
spec[["ODE"]] <- unlist(spec[names(spec)=="ODE"], use.names = FALSE)
}
if("PLUGIN" %in% names(spec)) {
spec[["PLUGIN"]] <- unlist(spec[names(spec)=="PLUGIN"], use.names = FALSE)
}

# TODO: deprecate audit argument
mread.env[["audit_dadt"]] <-
Expand Down Expand Up @@ -431,7 +436,7 @@ mread <- function(model, project = getOption("mrgsolve.project", getwd()),
x <- update_capture(x, .ren.chr(capture_vars))
build$preclean <- TRUE
}

# Check mod ----
check_pkmodel(x, subr, spec)
check_globals(mread.env[["move_global"]], Cmt(x))
Expand Down Expand Up @@ -555,7 +560,7 @@ mread <- function(model, project = getOption("mrgsolve.project", getwd()),
from = temp_write,
to = build[["compfile"]]
)

if(!compile) return(x)

if(ignore.stdout & !quiet) {
Expand Down

0 comments on commit c933a69

Please sign in to comment.