Skip to content

Commit

Permalink
Missing time.dose in pk.calc.c0() will not cause an error
Browse files Browse the repository at this point in the history
  • Loading branch information
billdenney committed Dec 11, 2024
1 parent 4246ff3 commit cfd235f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ the inclusion of IV NCA parameters and additional specifications of
the dosing including dose amount and route.

# PKNCA 0.11.0.9000

* PKNCA will now give an error when there are unexpected interval columns.
The `keep_interval_cols` option can be used to mitigate this error.
* PKNCA will now make verifications on the `intervals` object within the
Expand All @@ -17,6 +18,7 @@ the dosing including dose amount and route.
error. (#298)
* Removed native pipes (`|>`) so that PKNCA will work with older versions of R
(#304).
* Missing dosing times to `pk.calc.c0()` will not cause an error (#344)

# PKNCA 0.11.0

Expand Down
10 changes: 7 additions & 3 deletions R/pk.calc.c0.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ pk.calc.c0 <- function(conc, time, time.dose=0,
if (check) {
assert_conc_time(conc = conc, time = time)
}
if (length(time.dose) != 1)
if (length(time.dose) != 1) {
stop("time.dose must be a scalar")
if (!is.numeric(time.dose) | is.factor(time.dose))
} else if (!is.numeric(time.dose) | is.factor(time.dose)) {
stop("time.dose must be a number")
if (time.dose > max(time)) {
}
if (is.na(time.dose)) {
warning("time.dose is NA")
return(NA)
} else if (time.dose > max(time)) {
warning("time.dose is after all available data")
return(NA)
}
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-pk.calc.c0.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ test_that("pk.calc.c0", {
expect_error(pk.calc.c0(5:1, 0:4, method="blah"),
regexp="should be one of",
info="method must be valid")
expect_warning(
pk.calc.c0(conc = 0:3, time = 0:3, time.dose = NA_real_),
regexp = "time.dose is NA"
)
expect_warning(pk.calc.c0(5:1, 0:4, time.dose=30),
regexp="time.dose is after all available data")

Expand Down

0 comments on commit cfd235f

Please sign in to comment.