Skip to content

Commit

Permalink
added test for ic_tbl sort_by = "none" and improved other ic_tbl tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed Jan 22, 2024
1 parent d6c63ff commit af2695c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,39 @@ test_that("get_param fails as expected with incorrect parameters", {
})

test_that("ic_tbl works as expected", {
set.seed(1)
cases <- rnbinom(n = 100, mu = 5, size = 0.7)
pois_fit <- fitdistrplus::fitdist(data = cases, distr = "pois")
geom_fit <- fitdistrplus::fitdist(data = cases, distr = "geom")
nbinom_fit <- fitdistrplus::fitdist(data = cases, distr = "nbinom")
tbl <- ic_tbl(pois_fit, geom_fit, nbinom_fit)
expect_s3_class(tbl, class = "data.frame")
expect_identical(dim(tbl), c(3L, 7L))
expect_identical(tbl$distribution, c("nbinom", "geom", "pois"))
})

test_that("ic_tbl works as expected with sort_by = BIC", {
set.seed(1)
cases <- rnbinom(n = 100, mu = 5, size = 0.7)
pois_fit <- fitdistrplus::fitdist(data = cases, distr = "pois")
geom_fit <- fitdistrplus::fitdist(data = cases, distr = "geom")
nbinom_fit <- fitdistrplus::fitdist(data = cases, distr = "nbinom")
tbl <- ic_tbl(pois_fit, geom_fit, nbinom_fit, sort_by = "BIC")
expect_s3_class(tbl, class = "data.frame")
expect_identical(dim(tbl), c(3L, 7L))
expect_identical(tbl$distribution, c("nbinom", "geom", "pois"))
})

test_that("ic_tbl works as expected with sort_by = none", {
set.seed(1)
cases <- rnbinom(n = 100, mu = 5, size = 0.7)
pois_fit <- fitdistrplus::fitdist(data = cases, distr = "pois")
geom_fit <- fitdistrplus::fitdist(data = cases, distr = "geom")
nbinom_fit <- fitdistrplus::fitdist(data = cases, distr = "nbinom")
tbl <- ic_tbl(pois_fit, geom_fit, nbinom_fit, sort_by = "none")
expect_s3_class(tbl, class = "data.frame")
expect_identical(dim(tbl), c(3L, 7L))
expect_identical(tbl$distribution, c("pois", "geom", "nbinom"))
})

test_that("ic_tbl fails as expected", {
Expand Down

0 comments on commit af2695c

Please sign in to comment.