Skip to content

Commit

Permalink
Test/fix blank model variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Aug 3, 2024
1 parent 0145751 commit f207271
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
47 changes: 41 additions & 6 deletions src/rxData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,8 @@ List rxModelVars_rxode2(const RObject &obj){
//'
//' @noRd
List rxModelVars_blank() {
List ret(20);
CharacterVector retN(20);
List ret(24);
CharacterVector retN(24);
ret[0] = CharacterVector::create(); // params
retN[0] = "params";
ret[1] = CharacterVector::create(); // lhs
Expand Down Expand Up @@ -773,10 +773,45 @@ List rxModelVars_blank() {
retN[15] = "dvid";
ret[16] = List::create();
retN[16] = "indLin";
ret[17] = IntegerVector::create(0); // timeId
retN[17] = "timeId";
ret[18] =CharacterVector::create(_["file_md5"] = "", _["parsed_md5"] = ""); // md5
retN[18] = "md5";

ret[17] = IntegerVector::create(_["ncmt"] = 0,
_["ka"] = 0,
_["linB"] = 0,
_["maxeta"] = 0,
_["maxtheta"] = 0,
_["hasCmt"] = 0,
_["linCmt"] = -100,
_["linCmtFlg"] = 0,
_["nIndSim"] = 0,
_["simflg"] = 0,
_["thread"] = 0,
_["nLlik"] = 0); // flags
retN[17] = "flags";

ret[18] = CharacterVector::create();
retN[18] = "slhs";

ret[19] = CharacterVector::create();
retN[19] = "alag";

ret[20] = IntegerVector::create(0); // timeId
retN[20] = "udf";

IntegerVector interp = IntegerVector::create();
interp.attr("names") = CharacterVector::create();
interp.attr("levels") = CharacterVector::create("default", "linear", "locf", "nocb", "midpoint");
interp.attr("class") = "factor";
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;
ret.attr("class") = "rxModelVars";
return ret;
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-000-modelVars.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ d/dt(y3) = a3*y1*y2
rigid_compare <- rigid_compare[setdiff(names(rigid_compare), "timeId")]
expect_equal(rigid0_compare, rigid_compare)
})

test_that("blank modelvars has same size", {
blank <- rxModelVars("")
full <- rxModelVars("y = 1")
expect_equal(length(rxModelVars(blank)), length(full))
})
})

0 comments on commit f207271

Please sign in to comment.