Skip to content

Commit

Permalink
fix a few lints
Browse files Browse the repository at this point in the history
Thanks `{flint}`
  • Loading branch information
IndrajeetPatil committed Jul 26, 2024
1 parent 5a164e5 commit c9c438a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions tests/testthat/test-bayesfactor_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ test_that("bayesfactor_parameters data frame", {

# interval
expect_warning(
bfsd <- bayesfactor_parameters(Xposterior, prior = Xprior, null = c(-.1, .1), direction = 0),
bfsd <- bayesfactor_parameters(Xposterior, prior = Xprior, null = c(-0.1, 0.1), direction = 0),
regexp = NA
)
expect_equal(bfsd$log_BF, c(0.13, 0.13), tolerance = 0.1)

bfsd <- bayesfactor_parameters(Xposterior, prior = Xprior, null = c(-.1, .1), direction = 1)
bfsd <- bayesfactor_parameters(Xposterior, prior = Xprior, null = c(-0.1, 0.1), direction = 1)
expect_equal(bfsd$log_BF, c(0.47, -0.39), tolerance = 0.1)

bfsd <- bayesfactor_parameters(Xposterior, prior = Xprior, null = c(-.1, .1), direction = -1)
bfsd <- bayesfactor_parameters(Xposterior, prior = Xprior, null = c(-0.1, 0.1), direction = -1)
expect_equal(bfsd$log_BF, c(-0.39, 0.47), tolerance = 0.1)

# interval with inf
bfsd <- bayesfactor_parameters(Xposterior, prior = Xprior, null = c(-.1, Inf))
bfsd <- bayesfactor_parameters(Xposterior, prior = Xprior, null = c(-0.1, Inf))
expect_equal(bfsd$log_BF, c(-0.81, 0.80), tolerance = 0.1)

bfsd <- bayesfactor_parameters(Xposterior, prior = Xprior, null = c(-Inf, .1))
bfsd <- bayesfactor_parameters(Xposterior, prior = Xprior, null = c(-Inf, 0.1))
expect_equal(bfsd$log_BF, c(0.80, -0.81), tolerance = 0.1)
})

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-bayesfactor_restricted.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ test_that("bayesfactor_restricted df", {
)

posterior <- data.frame(
X = distribution_normal(100, .4, .2),
X1 = distribution_normal(100, -.2, .2),
X3 = distribution_normal(100, .2)
X = distribution_normal(100, 0.4, 0.2),
X1 = distribution_normal(100, -0.2, 0.2),
X3 = distribution_normal(100, 0.2)
)

hyps <- c(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-brms.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test_that("brms", {
expect_s3_class(hdi(model), "data.frame")
expect_s3_class(ci(model), "data.frame")
expect_s3_class(rope(model, verbose = FALSE), "data.frame")
expect_true("equivalence_test" %in% class(equivalence_test(model)))
expect_true(inherits(equivalence_test(model), "equivalence_test"))
expect_s3_class(map_estimate(model), "data.frame")
expect_s3_class(p_map(model), "data.frame")
expect_s3_class(p_direction(model), "data.frame")
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-effective_sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test_that("effective_sample", {
data.frame(
Parameter = c("b_Intercept", "b_wt", "b_cyl"),
ESS = c(5242, 2071, 1951),
stringsAsFactors = F
stringsAsFactors = FALSE
)
)

Expand All @@ -22,7 +22,7 @@ test_that("effective_sample", {
data.frame(
Parameter = c("b_Intercept"),
ESS = c(2888),
stringsAsFactors = F
stringsAsFactors = FALSE
)
)

Expand All @@ -33,7 +33,7 @@ test_that("effective_sample", {
data.frame(
Parameter = c("b_Intercept"),
ESS = c(1059),
stringsAsFactors = F
stringsAsFactors = FALSE
)
)
})
2 changes: 1 addition & 1 deletion tests/testthat/test-emmGrid.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ test_that("emmGrid p_significance", {
})

test_that("emmGrid rope", {
xrope <- rope(all_, range = "default", ci = .9)
xrope <- rope(all_, range = "default", ci = 0.9)
expect_equal(length(xrope$ROPE_Percentage), 3)
})

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-rstanarm.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test_that("rstanarm", {
expect_s3_class(hdi(model), "data.frame")
expect_s3_class(ci(model), "data.frame")
expect_s3_class(rope(model, verbose = FALSE), "data.frame")
expect_true("equivalence_test" %in% class(equivalence_test(model)))
expect_true(inherits(equivalence_test(model), "equivalence_test"))
expect_s3_class(map_estimate(model), "data.frame")
expect_s3_class(p_map(model), "data.frame")
expect_s3_class(p_direction(model), "data.frame")
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-spi.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ test_that("spi", {
skip_if_not_or_load_if_installed("httr")
skip_if_not_or_load_if_installed("BayesFactor")

expect_equal(spi(distribution_normal(1000), ci = .90)$CI_low[1], -1.65, tolerance = 0.02)
expect_equal(nrow(spi(distribution_normal(1000), ci = c(.80, .90, .95))), 3, tolerance = 0.01)
expect_equal(spi(distribution_normal(1000), ci = 0.90)$CI_low[1], -1.65, tolerance = 0.02)
expect_equal(nrow(spi(distribution_normal(1000), ci = c(0.80, 0.90, 0.95))), 3, tolerance = 0.01)
expect_equal(spi(distribution_normal(1000), ci = 1)$CI_low[1], -3.29, tolerance = 0.02)
expect_equal(nchar(capture.output(print(spi(distribution_normal(1000))))), 22)
expect_equal(length(capture.output(print(spi(distribution_normal(1000), ci = c(.80, .90))))), 5)
expect_equal(length(capture.output(print(spi(distribution_normal(1000), ci = c(0.80, 0.90))))), 5)


expect_error(spi(c(2, 3, NA)))
Expand Down Expand Up @@ -63,7 +63,7 @@ test_that("ci - BayesFactor", {
skip_if_not_or_load_if_installed("httr")
skip_if_not_or_load_if_installed("BayesFactor")

mod_bf <- proportionBF(y = 15, N = 25, p = .5)
mod_bf <- proportionBF(y = 15, N = 25, p = 0.5)
p_bf <- insight::get_parameters(mod_bf)

expect_equal(
Expand Down

0 comments on commit c9c438a

Please sign in to comment.