Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto variable promotion in model piping append isn't working correctly #610

Closed
mattfidler opened this issue Dec 1, 2023 · 0 comments · Fixed by #612
Closed

auto variable promotion in model piping append isn't working correctly #610

mattfidler opened this issue Dec 1, 2023 · 0 comments · Fixed by #612

Comments

@mattfidler
Copy link
Member

  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
    }))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant