Skip to content

Commit

Permalink
Merge pull request #780 from nlmixr2/780-warning-solve
Browse files Browse the repository at this point in the history
Warning with solve
  • Loading branch information
mattfidler authored Sep 2, 2024
2 parents 771b204 + 88c353b commit b190a50
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/etTran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Binary file added tests/testthat/test-etTrans-780.qs
Binary file not shown.
68 changes: 68 additions & 0 deletions tests/testthat/test-etTrans.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

})

0 comments on commit b190a50

Please sign in to comment.