Skip to content

Commit

Permalink
Add some more tests and change numeric and character values
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Dec 5, 2024
1 parent 0ffe33f commit f958440
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 53 deletions.
96 changes: 48 additions & 48 deletions R/rxrandomui.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
.mean <- as.character(substitute(mean))
.tmp <- suppressWarnings(try(force(mean), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.mean <- mean
}
}
.sd <- as.character(substitute(sd))
.tmp <- suppressWarnings(try(force(sd), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.sd <- sd
}
}
Expand All @@ -28,7 +28,7 @@ rxUdfUi.rxnorm <- rxUdfUi.rxpois
.lambda <- as.character(substitute(lambda))
.tmp <- suppressWarnings(try(force(lambda), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.lambda <- lambda
}
}
Expand All @@ -45,7 +45,7 @@ rxUdfUi.rxpois <- rxUdfUi.rxpois
.df <- as.character(substitute(df))
.tmp <- suppressWarnings(try(force(df), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.df <- df
}
}
Expand All @@ -62,14 +62,14 @@ rxUdfUi.rxt <- rxUdfUi.rxpois
.min <- as.character(substitute(min))
.tmp <- suppressWarnings(try(force(min), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.min <- min
}
}
.max <- as.character(substitute(max))
.tmp <- suppressWarnings(try(force(max), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.max <- max
}
}
Expand All @@ -86,18 +86,18 @@ rxUdfUi.rxunif <- rxUdfUi.rxpois
.shape <- as.character(substitute(shape))
.tmp <- suppressWarnings(try(force(shape), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.shape <- shape
}
}
.scale <- as.character(substitute(scale))
.tmp <- suppressWarnings(try(force(scale), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.scale <- scale
}
}
list(replace = paste0("rxweibull(", .shape, ", ", .scale,
list(replace = paste0("rxweibull(", .shape, ", ", .scale,
")"))
}

Expand All @@ -111,7 +111,7 @@ rxUdfUi.rxweibull <- rxUdfUi.rxpois
.prob <- as.character(substitute(prob))
.tmp <- suppressWarnings(try(force(prob), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.prob <- prob
}
}
Expand All @@ -128,18 +128,18 @@ rxUdfUi.rxgeom <- rxUdfUi.rxpois
.shape1 <- as.character(substitute(shape1))
.tmp <- suppressWarnings(try(force(shape1), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.shape1 <- shape1
}
}
.shape2 <- as.character(substitute(shape2))
.tmp <- suppressWarnings(try(force(shape2), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.shape2 <- shape2
}
}
list(replace = paste0("rxbeta(", .shape1, ", ", .shape2,
list(replace = paste0("rxbeta(", .shape1, ", ", .shape2,
")"))
}

Expand All @@ -153,14 +153,14 @@ rxUdfUi.rxbeta <- rxUdfUi.rxpois
.shape <- as.character(substitute(shape))
.tmp <- suppressWarnings(try(force(shape), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.shape <- shape
}
}
.rate <- as.character(substitute(rate))
.tmp <- suppressWarnings(try(force(rate), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.rate <- rate
}
}
Expand All @@ -177,14 +177,14 @@ rxUdfUi.rxgamma <- rxUdfUi.rxpois
.df1 <- as.character(substitute(df1))
.tmp <- suppressWarnings(try(force(df1), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.df1 <- df1
}
}
.df2 <- as.character(substitute(df2))
.tmp <- suppressWarnings(try(force(df2), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.df2 <- df2
}
}
Expand All @@ -201,7 +201,7 @@ rxUdfUi.rxf <- rxUdfUi.rxpois
.rate <- as.character(substitute(rate))
.tmp <- suppressWarnings(try(force(rate), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.rate <- rate
}
}
Expand All @@ -218,7 +218,7 @@ rxUdfUi.rxexp <- rxUdfUi.rxpois
.df <- as.character(substitute(df))
.tmp <- suppressWarnings(try(force(df), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.df <- df
}
}
Expand All @@ -235,18 +235,18 @@ rxUdfUi.rxchisq <- rxUdfUi.rxpois
.location <- as.character(substitute(location))
.tmp <- suppressWarnings(try(force(location), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.location <- location
}
}
.scale <- as.character(substitute(scale))
.tmp <- suppressWarnings(try(force(scale), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.scale <- scale
}
}
list(replace = paste0("rxcauchy(", .location, ", ", .scale,
list(replace = paste0("rxcauchy(", .location, ", ", .scale,
")"))
}

Expand All @@ -260,14 +260,14 @@ rxUdfUi.rxcauchy <- rxUdfUi.rxpois
.size <- as.character(substitute(size))
.tmp <- suppressWarnings(try(force(size), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.size <- size
}
}
.prob <- as.character(substitute(prob))
.tmp <- suppressWarnings(try(force(prob), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.prob <- prob
}
}
Expand All @@ -284,14 +284,14 @@ rxUdfUi.rxbinom <- rxUdfUi.rxpois
.mean <- as.character(substitute(mean))
.tmp <- suppressWarnings(try(force(mean), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.mean <- mean
}
}
.sd <- as.character(substitute(sd))
.tmp <- suppressWarnings(try(force(sd), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.sd <- sd
}
}
Expand All @@ -308,7 +308,7 @@ rxUdfUi.rinorm <- rxUdfUi.rxpois
.lambda <- as.character(substitute(lambda))
.tmp <- suppressWarnings(try(force(lambda), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.lambda <- lambda
}
}
Expand All @@ -325,7 +325,7 @@ rxUdfUi.ripois <- rxUdfUi.rxpois
.df <- as.character(substitute(df))
.tmp <- suppressWarnings(try(force(df), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.df <- df
}
}
Expand All @@ -342,14 +342,14 @@ rxUdfUi.rit <- rxUdfUi.rxpois
.min <- as.character(substitute(min))
.tmp <- suppressWarnings(try(force(min), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.min <- min
}
}
.max <- as.character(substitute(max))
.tmp <- suppressWarnings(try(force(max), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.max <- max
}
}
Expand All @@ -366,18 +366,18 @@ rxUdfUi.riunif <- rxUdfUi.rxpois
.shape <- as.character(substitute(shape))
.tmp <- suppressWarnings(try(force(shape), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.shape <- shape
}
}
.scale <- as.character(substitute(scale))
.tmp <- suppressWarnings(try(force(scale), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.scale <- scale
}
}
list(replace = paste0("riweibull(", .shape, ", ", .scale,
list(replace = paste0("riweibull(", .shape, ", ", .scale,
")"))
}

Expand All @@ -391,7 +391,7 @@ rxUdfUi.riweibull <- rxUdfUi.rxpois
.prob <- as.character(substitute(prob))
.tmp <- suppressWarnings(try(force(prob), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.prob <- prob
}
}
Expand All @@ -408,18 +408,18 @@ rxUdfUi.rigeom <- rxUdfUi.rxpois
.shape1 <- as.character(substitute(shape1))
.tmp <- suppressWarnings(try(force(shape1), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.shape1 <- shape1
}
}
.shape2 <- as.character(substitute(shape2))
.tmp <- suppressWarnings(try(force(shape2), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.shape2 <- shape2
}
}
list(replace = paste0("ribeta(", .shape1, ", ", .shape2,
list(replace = paste0("ribeta(", .shape1, ", ", .shape2,
")"))
}

Expand All @@ -433,14 +433,14 @@ rxUdfUi.ribeta <- rxUdfUi.rxpois
.shape <- as.character(substitute(shape))
.tmp <- suppressWarnings(try(force(shape), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.shape <- shape
}
}
.rate <- as.character(substitute(rate))
.tmp <- suppressWarnings(try(force(rate), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.rate <- rate
}
}
Expand All @@ -457,14 +457,14 @@ rxUdfUi.rigamma <- rxUdfUi.rxpois
.df1 <- as.character(substitute(df1))
.tmp <- suppressWarnings(try(force(df1), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.df1 <- df1
}
}
.df2 <- as.character(substitute(df2))
.tmp <- suppressWarnings(try(force(df2), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.df2 <- df2
}
}
Expand All @@ -481,7 +481,7 @@ rxUdfUi.rif <- rxUdfUi.rxpois
.rate <- as.character(substitute(rate))
.tmp <- suppressWarnings(try(force(rate), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.rate <- rate
}
}
Expand All @@ -498,7 +498,7 @@ rxUdfUi.riexp <- rxUdfUi.rxpois
.df <- as.character(substitute(df))
.tmp <- suppressWarnings(try(force(df), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.df <- df
}
}
Expand All @@ -515,18 +515,18 @@ rxUdfUi.richisq <- rxUdfUi.rxpois
.location <- as.character(substitute(location))
.tmp <- suppressWarnings(try(force(location), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.location <- location
}
}
.scale <- as.character(substitute(scale))
.tmp <- suppressWarnings(try(force(scale), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.scale <- scale
}
}
list(replace = paste0("ricauchy(", .location, ", ", .scale,
list(replace = paste0("ricauchy(", .location, ", ", .scale,
")"))
}

Expand All @@ -540,14 +540,14 @@ rxUdfUi.ricauchy <- rxUdfUi.rxpois
.size <- as.character(substitute(size))
.tmp <- suppressWarnings(try(force(size), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.size <- size
}
}
.prob <- as.character(substitute(prob))
.tmp <- suppressWarnings(try(force(prob), silent = TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
if (is.character(.tmp) || is.numeric(.tmp)) {
.prob <- prob
}
}
Expand Down
Loading

0 comments on commit f958440

Please sign in to comment.