Skip to content

Commit

Permalink
uncomment tests to force to deal with them
Browse files Browse the repository at this point in the history
if they are not needed, remove them
  • Loading branch information
IndrajeetPatil committed Jul 31, 2023
1 parent 47d1512 commit dc049fd
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 50 deletions.
4 changes: 3 additions & 1 deletion R/map_estimate.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ map_estimate <- function(x, precision = 2^10, method = "kernel", ...) {
#' @export
map_estimate.numeric <- function(x, precision = 2^10, method = "kernel", ...) {
out <- map_estimate(data.frame(x = x),
precision, method = method, ...)
precision,
method = method, ...
)
out[[1]] <- NULL
attr(out, "data") <- x
out
Expand Down
30 changes: 15 additions & 15 deletions tests/testthat/test-blavaan.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ test_that("blavaan, all", {
x <- suppressWarnings(weighted_posteriors(bfit, bfit2))
expect_identical(ncol(x), 14L)

# bfit_prior <- unupdate(bfit)
# capture.output(x <- expect_warning(bayesfactor_parameters(bfit, prior = bfit_prior)))
# expect_identical(nrow(x), 14L)
#
# x <- expect_warning(si(bfit, prior = bfit_prior))
# expect_identical(nrow(x), 14L)
#
# ## Prior/posterior checks ----
# suppressWarnings(x <- check_prior(bfit))
# expect_equal(nrow(x), 13)
#
# x <- check_prior(bfit, simulate_priors = FALSE)
# expect_identical(nrow(x), 14L)
bfit_prior <- unupdate(bfit)
capture.output(x <- expect_warning(bayesfactor_parameters(bfit, prior = bfit_prior)))
expect_identical(nrow(x), 14L)

x <- expect_warning(si(bfit, prior = bfit_prior))
expect_identical(nrow(x), 14L)

## Prior/posterior checks ----
suppressWarnings(x <- check_prior(bfit))
expect_equal(nrow(x), 13)

x <- check_prior(bfit, simulate_priors = FALSE)
expect_identical(nrow(x), 14L)

x <- diagnostic_posterior(bfit)
expect_identical(nrow(x), 14L)
Expand All @@ -107,6 +107,6 @@ test_that("blavaan, all", {
expect_identical(nrow(x), 13L)
# YES this is 13! We have two parameters with the same prior.

# x <- describe_posterior(bfit, test = "all", rope_range = c(-0.1, 0.1))
# expect_identical(nrow(x), 14L)
x <- describe_posterior(bfit, test = "all", rope_range = c(-0.1, 0.1))
expect_identical(nrow(x), 14L)
})
16 changes: 8 additions & 8 deletions tests/testthat/test-different_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ test_that("insight::get_predicted", {
rez <- p_direction(x)
expect_equal(c(nrow(rez), ncol(rez)), c(32, 2))

# rez <- p_map(x)
# expect_equal(c(nrow(rez), ncol(rez)), c(2, 2))
#
# rez <- p_significance(x)
# expect_equal(c(nrow(rez), ncol(rez)), c(2, 2))
#
# rez <- rope(x)
# expect_equal(c(nrow(rez), ncol(rez)), c(2, 5))
rez <- p_map(x)
expect_equal(c(nrow(rez), ncol(rez)), c(2, 2))

rez <- p_significance(x)
expect_equal(c(nrow(rez), ncol(rez)), c(2, 2))

rez <- rope(x)
expect_equal(c(nrow(rez), ncol(rez)), c(2, 5))

rez <- describe_posterior(x)
expect_equal(c(nrow(rez), ncol(rez)), c(32, 5))
Expand Down
51 changes: 25 additions & 26 deletions tests/testthat/test-rope.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ test_that("rope", {

expect_equal(equivalence_test(distribution_normal(1000, 0, 0.001), ci = 1)$ROPE_Equivalence, "Accepted")

# print(rope(rnorm(1000, mean = 0, sd = 3), ci = .5))
expect_equal(rope(rnorm(1000, mean = 0, sd = 3), ci = c(.1, .5, .9), verbose = FALSE)$CI, c(.1, .5, .9))

x <- equivalence_test(distribution_normal(1000, 1, 1), ci = c(.50, .99))
Expand Down Expand Up @@ -71,31 +70,31 @@ test_that("rope", {
})


# if ( skip_if_not_or_load_if_installed("brms")) {
# set.seed(123)
# model <- brm(mpg ~ wt + gear, data = mtcars, iter = 500)
# rope <- rope(model, verbose = FALSE)
#
# test_that("rope (brms)", {
# expect_equal(rope$ROPE_high, -rope$ROPE_low, tolerance = 0.01)
# expect_equal(rope$ROPE_high[1], 0.6026948)
# expect_equal(rope$ROPE_Percentage, c(0.00, 0.00, 0.50), tolerance = 0.1)
# })
#
# model <- brm(mvbind(mpg, disp) ~ wt + gear, data = mtcars, iter = 500)
# rope <- rope(model, verbose = FALSE)
#
# test_that("rope (brms, multivariate)", {
# expect_equal(rope$ROPE_high, -rope$ROPE_low, tolerance = 0.01)
# expect_equal(rope$ROPE_high[1], 0.6026948, tolerance = 0.01)
# expect_equal(rope$ROPE_high[4], 12.3938694, tolerance = 0.01)
# expect_equal(
# rope$ROPE_Percentage,
# c(0, 0, 0.493457, 0.072897, 0, 0.508411),
# tolerance = 0.1
# )
# })
# }
skip_if_not_or_load_if_installed("brms")
set.seed(123)
model <- brm(mpg ~ wt + gear, data = mtcars, iter = 500)
rope <- rope(model, verbose = FALSE)

test_that("rope (brms)", {
expect_equal(rope$ROPE_high, -rope$ROPE_low, tolerance = 0.01)
expect_equal(rope$ROPE_high[1], 0.6026948)
expect_equal(rope$ROPE_Percentage, c(0.00, 0.00, 0.50), tolerance = 0.1)
})

model <- brm(mvbind(mpg, disp) ~ wt + gear, data = mtcars, iter = 500)
rope <- rope(model, verbose = FALSE)

test_that("rope (brms, multivariate)", {
expect_equal(rope$ROPE_high, -rope$ROPE_low, tolerance = 0.01)
expect_equal(rope$ROPE_high[1], 0.6026948, tolerance = 0.01)
expect_equal(rope$ROPE_high[4], 12.3938694, tolerance = 0.01)
expect_equal(
rope$ROPE_Percentage,
c(0, 0, 0.493457, 0.072897, 0, 0.508411),
tolerance = 0.1
)
})


test_that("BayesFactor", {
skip_if_not_or_load_if_installed("BayesFactor")
Expand Down

0 comments on commit dc049fd

Please sign in to comment.