Skip to content

Commit

Permalink
use numeric NAs in clean_epidist_params
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed Aug 18, 2023
1 parent ce1d2fe commit 2d9e08c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions R/epidist_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ clean_epidist_params.gamma <- function(prob_dist_params) {

# if unparameterised return named vector of NAs
if (isTRUE(is.na(prob_dist_params))) {
prob_dist_params <- c(shape = NA, scale = NA)
prob_dist_params <- c(shape = NA_real_, scale = NA_real_)
return(prob_dist_params)
}

Expand Down Expand Up @@ -588,7 +588,7 @@ clean_epidist_params.lnorm <- function(prob_dist_params) {

# if unparameterised return named vector of NAs
if (isTRUE(is.na(prob_dist_params))) {
prob_dist_params <- c(meanlog = NA, sdlog = NA)
prob_dist_params <- c(meanlog = NA_real_, sdlog = NA_real_)
return(prob_dist_params)
}

Expand Down Expand Up @@ -630,7 +630,7 @@ clean_epidist_params.weibull <- function(prob_dist_params) {

# if unparameterised return named vector of NAs
if (isTRUE(is.na(prob_dist_params))) {
prob_dist_params <- c(shape = NA, scale = NA)
prob_dist_params <- c(shape = NA_real_, scale = NA_real_)
return(prob_dist_params)
}

Expand Down Expand Up @@ -658,7 +658,7 @@ clean_epidist_params.nbinom <- function(prob_dist_params) {

# if unparameterised return named vector of NAs
if (isTRUE(is.na(prob_dist_params))) {
prob_dist_params <- c(mean = NA, dispersion = NA)
prob_dist_params <- c(mean = NA_real_, dispersion = NA_real_)
return(prob_dist_params)
}

Expand Down Expand Up @@ -708,7 +708,7 @@ clean_epidist_params.geom <- function(prob_dist_params) {

# if unparameterised return named NA
if (isTRUE(is.na(prob_dist_params))) {
prob_dist_params <- c(prob = NA)
prob_dist_params <- c(prob = NA_real_)
return(prob_dist_params)
}

Expand Down Expand Up @@ -764,7 +764,7 @@ clean_epidist_params.pois <- function(prob_dist_params) {

# if unparameterised return named NA
if (isTRUE(is.na(prob_dist_params))) {
prob_dist_params <- c(mean = NA)
prob_dist_params <- c(mean = NA_real_)
return(prob_dist_params)
}

Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-epidist_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,27 @@ test_that("clean_epidist_params works for unparameterised (NA), (#161)", {
params <- NA
class(params) <- "gamma"
res <- clean_epidist_params(prob_dist_params = params)
expect_identical(res, c(shape = NA, scale = NA))
expect_identical(res, c(shape = NA_real_, scale = NA_real_))

class(params) <- "lnorm"
res <- clean_epidist_params(prob_dist_params = params)
expect_identical(res, c(meanlog = NA, sdlog = NA))
expect_identical(res, c(meanlog = NA_real_, sdlog = NA_real_))

class(params) <- "weibull"
res <- clean_epidist_params(prob_dist_params = params)
expect_identical(res, c(shape = NA, scale = NA))
expect_identical(res, c(shape = NA_real_, scale = NA_real_))

class(params) <- "nbinom"
res <- clean_epidist_params(prob_dist_params = params)
expect_identical(res, c(mean = NA, dispersion = NA))
expect_identical(res, c(mean = NA_real_, dispersion = NA_real_))

class(params) <- "geom"
res <- clean_epidist_params(prob_dist_params = params)
expect_identical(res, c(prob = NA))
expect_identical(res, c(prob = NA_real_))

class(params) <- "pois"
res <- clean_epidist_params(prob_dist_params = params)
expect_identical(res, c(mean = NA))
expect_identical(res, c(mean = NA_real_))
})

test_that("create_epidist_region works as expected", {
Expand Down

0 comments on commit 2d9e08c

Please sign in to comment.