diff --git a/src/etTran.cpp b/src/etTran.cpp index dcae40f96..aa2c3e4a6 100644 --- a/src/etTran.cpp +++ b/src/etTran.cpp @@ -1242,7 +1242,7 @@ List etTrans(List inData, const RObject &obj, bool addCmt=false, } else if (lastId != cid) { lastId = cid; } else if (lastTime > ctime) { - if (inEvid[i] != 3 && inEvid[i] != 4) { + if (!hasEvid || (inEvid[i] != 3 && inEvid[i] != 4)) { isSorted = false; // The prior EVID=3 w/reset a reset time // REprintf("\t not sorted"); } else if (lastTime > ctime) { diff --git a/tests/testthat/test-etTrans-780.qs b/tests/testthat/test-etTrans-780.qs new file mode 100644 index 000000000..d7e71ee88 Binary files /dev/null and b/tests/testthat/test-etTrans-780.qs differ diff --git a/tests/testthat/test-etTrans.R b/tests/testthat/test-etTrans.R index dbe8ac90b..cc34eccc8 100644 --- a/tests/testthat/test-etTrans.R +++ b/tests/testthat/test-etTrans.R @@ -1379,3 +1379,71 @@ d/dt(blood) = a*intestine - b*blood expect_equal(tmp$II, c(24, 0, 0, 0)) }) }) + + +test_that("warning on translation (#780)", { + + p <- test_path("test-etTrans-780.qs") + skip_if_not(file.exists(p)) + dat <- qs::qread(p) + + m <- rxode2parse(" + param(Kpm_pop, V_pop, k_pop, k12_pop, k21_pop, ka_pop, + km_pop, a1_Cp, b1_Cp, a2_Cm, b2_Cm, omega_Kpm, omega_V, + omega_k, omega_k12, omega_k21, omega_ka, omega_km) + cmt(depot) + cmt(central) + cmt(cmt2) + cmt(cmt3) + Kpm = exp(Kpm_pop + omega_Kpm) + V = exp(V_pop + omega_V) + k = exp(k_pop + omega_k) + k12 = exp(k12_pop + omega_k12) + k21 = exp(k21_pop + omega_k21) + ka = exp(ka_pop + omega_ka) + km = exp(km_pop + omega_km) + d/dt(depot) = -ka * depot + d/dt(central) = -k12 * central + k21 * cmt2 + ka * depot - + k * central - Kpm * central + Cp = central/V + d/dt(cmt2) = +k12 * central - k21 * cmt2 + d/dt(cmt3) = +Kpm * central - km * cmt3 + Cm = cmt3/V + y1_Cp = Cp + if (CMT == 5) { + rx_yj_ ~ 2 + rx_lambda_ ~ 1 + rx_low_ ~ 0 + rx_hi_ ~ 1 + rx_pred_f_ ~ y1_Cp + rx_pred_ ~ rx_pred_f_ + rx_r_ ~ ((a1_Cp) + (rx_pred_f_) * (b1_Cp))^2 + ipredSim = rxTBSi(rx_pred_, rx_lambda_, rx_yj_, rx_low_, + rx_hi_) + sim = rxTBSi(rx_pred_ + sqrt(rx_r_) * rxerr.y1_Cp, + rx_lambda_, rx_yj_, rx_low_, rx_hi_) + } + y2_Cm = Cm + if (CMT == 6) { + rx_yj_ ~ 2 + rx_lambda_ ~ 1 + rx_low_ ~ 0 + rx_hi_ ~ 1 + rx_pred_f_ ~ y2_Cm + rx_pred_ ~ rx_pred_f_ + rx_r_ ~ ((a2_Cm) + (rx_pred_f_) * (b2_Cm))^2 + ipredSim = rxTBSi(rx_pred_, rx_lambda_, rx_yj_, rx_low_, + rx_hi_) + sim = rxTBSi(rx_pred_ + sqrt(rx_r_) * rxerr.y2_Cm, + rx_lambda_, rx_yj_, rx_low_, rx_hi_) + } + iwres = (DV - rx_pred_)/sqrt(rx_r_) + ires = DV - rx_pred_ + cmt(y1_Cp) + cmt(y2_Cm) + dvid(5, 6) + ") + + expect_warning(etTrans(dat, m), NA) + +})