Skip to content

Commit

Permalink
Merge pull request #191 from billdenney/dup-ppstresu
Browse files Browse the repository at this point in the history
Allow duplicated PPSTRESU
  • Loading branch information
billdenney authored Oct 19, 2022
2 parents 555b723 + 6da5cff commit 46a7091
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/unit-support.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ pknca_units_table <- function(concu, doseu, amountu, timeu, conversions=data.fra
}
if (nrow(conversions) > 0) {
stopifnot(!duplicated(conversions$PPORRESU))
stopifnot(!duplicated(conversions$PPSTRESU))
# PPSTRESU may be duplicated because some differing original units may
# converge (e.g. cmax.dn and vss)
stopifnot(length(setdiff(names(conversions), c("PPORRESU", "PPSTRESU", "conversion_factor"))) == 0)
if (!("conversion_factor" %in% names(conversions))) {
if (!requireNamespace("units", quietly=TRUE)) {
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/test-unit-support.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,15 @@ test_that("pknca_units_table treats missing, NULL, and NA the same", {
dplyr::pull("PPORRESU")
)))
})

test_that("allow duplicate PPSTRESU units", {
d_conversion <-
data.frame(
PPORRESU = c("ng/mL", "(ng/mL)/(mg/kg)", "(mg/kg)/(hr*ng/mL)", "(mg/kg)/(ng/mL)"),
PPSTRESU = c("mg/mL", "mL/kg", "mL/(h*kg)", "mL/kg")
)
# No error for consistent volume conversion
expect_silent(
pknca_units_table(concu = "ng/mL", doseu = "mg/kg", timeu = "hr", conversions = d_conversion)
)
})

0 comments on commit 46a7091

Please sign in to comment.