Skip to content

Commit

Permalink
Check that dose.points is compatible with the number of signals avail…
Browse files Browse the repository at this point in the history
…able.
  • Loading branch information
mcol committed Sep 16, 2024
1 parent 8499237 commit ff15efb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions R/analyse_SAR.TL.R
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ analyse_SAR.TL <- function(
TL.background.ID <- temp.sequence.structure[
temp.sequence.structure[,"protocol.step"] == "BACKGROUND","id"]

## check that `dose.points` is compatible with our signals:
## as we expect each signal to have an Lx and a Tx components (see calls
## to calc_TLLxTxRatio()), `dose.points` must divide `length(TL.signal.ID)`
## in order for vector recycling to work when further down we do
## `LnLxTnTx$Dose <- dose.points`
if (!missing(dose.points)) {
if ((length(TL.signal.ID) / 2) %% length(dose.points) != 0) {
.throw_error("Length of 'dose.points' not compatible with number ",
"of signals")
}
}

##comfort ... translate integral limits from temperature to channel
if(integral_input == "temperature"){
signal.integral.min <-
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test_analyse_SAR.TL.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ test_that("input validation", {
expect_error(analyse_SAR.TL(object, signal.integral.min = 1,
signal.integral.max = 2),
"Input TL curves are not a multiple of the sequence structure")
expect_error(analyse_SAR.TL(object, dose.points = c(2, 2),
signal.integral.min = 210,
signal.integral.max = 220,
sequence.structure = c("SIGNAL", "BACKGROUND")),
"Length of 'dose.points' not compatible with number of signals")
})

test_that("Test examples", {
Expand Down

0 comments on commit ff15efb

Please sign in to comment.