Skip to content

Commit

Permalink
model variables from list now comes from blank
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Aug 3, 2024
1 parent f207271 commit e1f5771
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
1 change: 0 additions & 1 deletion R/rxsolve.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
51 changes: 30 additions & 21 deletions src/rxData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit e1f5771

Please sign in to comment.