Skip to content

Commit

Permalink
Add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Dec 1, 2023
1 parent b20e5b0 commit 5a56222
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/testthat/test-ui-piping.R
Original file line number Diff line number Diff line change
Expand Up @@ -1984,3 +1984,61 @@ test_that("off-diagonal piping issue #518", {
expect_error(modNew$omega, NA)

})

test_that("piping append", {

mod <- function() {
ini({
tka <- 0.45
label("Ka")
tcl <- 1
label("Cl")
tv <- 3.45
label("V")
add.sd <- c(0, 0.7)
eta.cl ~ 0.3
eta.v ~ 0.1
})
model({
ka <- exp(tka)
cl <- exp(tcl + eta.cl)
v <- exp(tv + eta.v)
d/dt(depot) = -ka * depot
d/dt(center) = ka * depot - cl/v * center
cp = center/v
cp ~ add(add.sd)
})
}

mod5 <- mod |>
model({
PD <- 1-emax*cp/(ec50+cp)
##
effect(0) <- e0
kin <- e0*kout
d/dt(effect) <- kin*PD -kout*effect
}, append=d/dt(center))

expect_equal(mod5$theta, c(tka = 0.45, tcl = 1, tv = 3.45, add.sd = 0.7))

mod6 <- mod5 |>
model({
emax <- exp(temax)
e0 <- exp(te0 + eta.e0)
ec50 <- exp(tec50)
kin <- exp(tkin)
kout <- exp(tkout)
}, append=NA)

expect_equal(mod6$theta,
c(tka = 0.45, tcl = 1, tv = 3.45, add.sd = 0.7, temax = 1, te0 = 1, tec50 = 1, tkin = 1, tkout = 1))

expect_equal(
mod6$omega,
lotri({
eta.cl ~ 0.3
eta.v ~ 0.1
eta.e0 ~ 1
}))

})

0 comments on commit 5a56222

Please sign in to comment.