Skip to content

Commit

Permalink
Add convertKinR0
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Aug 22, 2024
1 parent 1bdeae5 commit b6fdd58
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 13 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export(camelCombine)
export(combinePaste2)
export(convertEmax)
export(convertEmaxHill)
export(convertKinR0)
export(convertLogLin)
export(convertMM)
export(convertQuad)
Expand Down
2 changes: 1 addition & 1 deletion R/convertKinR0.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ convertKinR0 <- function(ui,
}
.modelLines <- .ui$lstExpr
.w <- .whichDdt(.modelLines, R, start="", end="(0)")
if (!length(.w)) {
if (length(.w) != 1L) {
stop(paste0("the model does not have the expected ",
R, "(0) expression"),
call.=FALSE)
Expand Down
32 changes: 32 additions & 0 deletions man/convertKinR0.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 1 addition & 12 deletions man/modeldb.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions tests/testthat/test-convertKinR0.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
test_that("test the convertKinR0 function", {

m <- addIndirect(stim="in") |> convertKinR0()

expect_true("uR0" %in% names(m$theta))

m2 <- m |> rxode2::model(a=kin, append=TRUE) |>
rxode2::model(R(0) <- kout) |>
rxode2::model(d/dt(R) <- -k*R) |>
rxode2::model(-R0)

expect_error(convertKinR0(m2))

m <- addIndirect(stim="in") |> rxode2::model(-R(0))

expect_error(m |> convertKinR0())

m <- addIndirect(stim="in") |>
rxode2::model(-d/dt(R))

expect_error(m |> convertKinR0())

})

0 comments on commit b6fdd58

Please sign in to comment.