Skip to content

Commit

Permalink
Merge pull request #1152 from metrumresearchgroup/fix/ev-now-time
Browse files Browse the repository at this point in the history
Never ignore .now doses based on .time
  • Loading branch information
kylebaron authored Jan 10, 2024
2 parents 46b5be9 + 5b45d53 commit 8ea7d8e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions inst/maintenance/unit-cpp/test-cpp.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,22 @@ test_that("mev lag times with F are respected", {
a <- filter_sims(a, A==max(A))
expect_identical(a$time, param(a)$t + param(a)$l + 0.5*mod$dose/param(a)$r)
})

code <- '
$CMT A
$MAIN
if(TIME==1) { // Give dose at TIME==1
mrgsolve::evdata ev(0, 1); // Set time to 0
ev.now = true; // Also set now to true
ev.amt = 100;
self.mevector.push_back(ev);
}
'

test_that("now doses are given even when time is past #1151", {
mod <- mcode("gh-1151", code)
out <- mrgsim(mod)
expect_false(all(out$A==0))
expect_equal(out$A[1], 0)
expect_equal(out$A[2], 100)
})
2 changes: 1 addition & 1 deletion src/devtran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ Rcpp::List DEVTRAN(const Rcpp::List parin,
for(size_t mti = 0; mti < mt.size(); ++mti) {
// Unpack and check
double this_time = (mt[mti]).time;
if(this_time < tto) continue;
if(this_time < tto && !mt[mti].now) continue;
unsigned int this_evid = (mt[mti]).evid;
if(this_evid==0) continue;
double this_amt = mt[mti].amt;
Expand Down

0 comments on commit 8ea7d8e

Please sign in to comment.