From e1f5771b5930b3b276195d82f408204afffe49be Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Sat, 3 Aug 2024 10:13:37 -0500 Subject: [PATCH] model variables from list now comes from blank --- R/rxsolve.R | 1 - src/rxData.cpp | 51 +++++++++++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/R/rxsolve.R b/R/rxsolve.R index ef9a6c23c..990c1d0ef 100644 --- a/R/rxsolve.R +++ b/R/rxsolve.R @@ -1774,7 +1774,6 @@ rxSolve.default <- function(object, params = NULL, events = NULL, inits = NULL, } .minfo(sprintf("omega/sigma items treated as zero: '%s'", paste(.ctl$.zeros, collapse="', '"))) } - if (rxode2.debug) { .envReset$ret <- .collectWarnings(rxSolveSEXP(object, .ctl, .nms, .xtra, params, events, inits, diff --git a/src/rxData.cpp b/src/rxData.cpp index dc8683302..7ed6e4aaf 100644 --- a/src/rxData.cpp +++ b/src/rxData.cpp @@ -804,12 +804,9 @@ List rxModelVars_blank() { ret[21] = interp; retN[21] = "interp"; - ret[22] = IntegerVector::create(0); // timeId retN[22] = "timeId"; - - ret[23] =CharacterVector::create(_["file_md5"] = "", _["parsed_md5"] = ""); // md5 retN[23] = "md5"; ret.attr("names") = retN; @@ -917,28 +914,40 @@ List rxModelVars_list(const RObject &obj) { bool params=false, lhs=false, state=false, trans=false, ini=false, model=false, md5=false, dfdy=false; List lobj = asList(obj, "rxModelVars_list"); CharacterVector nobj = lobj.names(); + // create a blank and then copy everthing over. to return a valid + // object need at least params, lhs, state, trans, ini, model, md5, + // and dfdy in the object + List blank = rxModelVars_blank(); + CharacterVector nobj2 = blank.names(); for (unsigned int i = 0; i < nobj.size(); i++){ if (nobj[i] == "modVars"){ return(rxModelVars_(lobj["modVars"])); - } else if (!params && nobj[i]== "params"){ - params=true; - } else if (!lhs && nobj[i] == "lhs"){ - lhs=true; - } else if (!state && nobj[i] == "state"){ - state=true; - } else if (!trans && nobj[i] == "trans"){ - trans=true; - } else if (!ini && nobj[i] == "ini"){ - ini = true; - } else if (!model && nobj[i] == "model"){ - model = true; - } else if (!md5 && nobj[i] == "md5"){ - md5 = true; - } else if (!dfdy && nobj[i] == "dfdy"){ - dfdy = true; - } else if (params && lhs && state && trans && ini && model && md5 && dfdy) { - return lobj; } + for (unsigned int j = 0; j < nobj2.size(); j++){ + if (nobj[i] == nobj2[j]){ + if (nobj[i] == "params"){ + params = true; + } else if (nobj[i] == "lhs"){ + lhs = true; + } else if (nobj[i] == "state"){ + state = true; + } else if (nobj[i] == "trans"){ + trans = true; + } else if (nobj[i] == "ini"){ + ini = true; + } else if (nobj[i] == "model"){ + model = true; + } else if (nobj[i] == "md5"){ + md5 = true; + } else if (nobj[i] == "dfdy"){ + dfdy = true; + } + break; + } + } + } + if (params && lhs && state && trans && ini && model && md5 && dfdy) { + return blank; } return rxModelVars_lastChance(obj); }