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

683 replace/remove is.probability/is.range/is.prob range with applicable additional checkmate assertions #692

Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/Rules-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -3017,7 +3017,7 @@ setMethod("stopTrial",
prob_target <- stopping@prob_target

## checks
stopifnot(is.probability(prob_target))
stopifnot(test_probability(prob_target))
dimitriskontosBAY marked this conversation as resolved.
Show resolved Hide resolved
stopifnot(is(Effmodel, "ModelEff"))
stopifnot(is(Effsamples, "Samples"))
stopifnot(is.function(TDderive))
Expand Down Expand Up @@ -3135,7 +3135,7 @@ setMethod("stopTrial",
prob_target <- stopping@prob_target

## checks
stopifnot(is.probability(prob_target))
stopifnot(test_probability(prob_target))
dimitriskontosBAY marked this conversation as resolved.
Show resolved Hide resolved
stopifnot(is(Effmodel, "ModelEff"))


Expand Down
14 changes: 7 additions & 7 deletions R/fromQuantiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Quantiles2LogisticNormal <- function(dosegrid,
identical(length(upper), nDoses),
all(lower < median),
all(upper > median),
is.probability(level, bounds = FALSE),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here used assert_probability and avoid stopifnot.

test_probability(level, bounds = FALSE),
identical(length(parlower), 5L),
identical(length(parupper), 5L),
all(parlower < parstart),
Expand Down Expand Up @@ -235,8 +235,8 @@ Quantiles2LogisticNormal <- function(dosegrid,
##' @keywords programming
getMinInfBeta <- function(p, q) {
stopifnot(
danielinteractive marked this conversation as resolved.
Show resolved Hide resolved
is.probability(p, bounds = FALSE),
is.probability(q, bounds = FALSE)
test_probability(p, bounds = FALSE),
test_probability(q, bounds = FALSE)
)

ret <-
Expand Down Expand Up @@ -311,10 +311,10 @@ MinimalInformative <- function(dosegrid,
nDoses <- length(dosegrid)
stopifnot(
!is.unsorted(dosegrid, strictly = TRUE),
is.probability(threshmin, bounds = FALSE),
is.probability(threshmax, bounds = FALSE),
is.probability(probmin, bounds = FALSE),
is.probability(probmax, bounds = FALSE)
test_probability(threshmin, bounds = FALSE),
danielinteractive marked this conversation as resolved.
Show resolved Hide resolved
test_probability(threshmax, bounds = FALSE),
test_probability(probmin, bounds = FALSE),
test_probability(probmax, bounds = FALSE)
)
xmin <- dosegrid[1]
xmax <- dosegrid[nDoses]
Expand Down
41 changes: 0 additions & 41 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,47 +149,6 @@ safeInteger <- function(x) {
as.integer(x)
}

##' Predicate checking for a probability
##'
##' @param x the object being checked
##' @param bounds whether to include the bounds 0 and 1 (default)
##' @return Returns \code{TRUE} if \code{x} is a probability
##'
##' @keywords internal
is.probability <- function(x,
bounds = TRUE) {
if (bounds) {
return(test_numeric(x, lower = 0, upper = 1, any.missing = FALSE))
} else {
return(test_numeric(x, lower = 0, upper = 1, any.missing = FALSE) && x != 0 && x != 1)
}
}

##' Predicate checking for a numeric range
##'
##' @param x the object being checked
##' @return Returns \code{TRUE} if \code{x} is a numeric range
##'
##' @keywords internal
is.range <- function(x) {
return(identical(length(x), 2L) &&
x[1] < x[2])
}

##' Predicate checking for a probability range
##'
##' @param x the object being checked
##' @param bounds whether to include the bounds 0 and 1 (default)
##' @return Returns \code{TRUE} if \code{x} is a probability range
##'
##' @keywords internal
is.probRange <- function(x,
bounds = TRUE) {
return(is.range(x) &&
all(sapply(x, is.probability, bounds = bounds)))
}


##' Shorthand for logit function
##'
##' @param x the function argument
Expand Down
20 changes: 0 additions & 20 deletions man/is.probRange.Rd

This file was deleted.

20 changes: 0 additions & 20 deletions man/is.probability.Rd

This file was deleted.

18 changes: 0 additions & 18 deletions man/is.range.Rd

This file was deleted.