diff --git a/R/hdi.R b/R/hdi.R index 39f2a9ac7..4fccb8898 100644 --- a/R/hdi.R +++ b/R/hdi.R @@ -382,7 +382,7 @@ hdi.get_predicted <- function(x, ...) { if (window_size < 2) { if (verbose) { - insight::format_message("`ci` is too small or x does not contain enough data points, returning NAs.") + insight::format_alert("`ci` is too small or x does not contain enough data points, returning NAs.") } return(data.frame( "CI" = ci, @@ -395,7 +395,7 @@ hdi.get_predicted <- function(x, ...) { if (nCIs < 1) { if (verbose) { - insight::format_message("`ci` is too large or x does not contain enough data points, returning NAs.") + insight::format_alert("`ci` is too large or x does not contain enough data points, returning NAs.") } return(data.frame( "CI" = ci, @@ -413,7 +413,7 @@ hdi.get_predicted <- function(x, ...) { if (n_candies > 1) { if (any(diff(sort(min_i)) != 1)) { if (verbose) { - insight::format_message("Identical densities found along different segments of the distribution, choosing rightmost.") + insight::format_alert("Identical densities found along different segments of the distribution, choosing rightmost.") } min_i <- max(min_i) } else { diff --git a/R/print.R b/R/print.R index 589b5c5a5..fbe3a2fd6 100644 --- a/R/print.R +++ b/R/print.R @@ -266,6 +266,7 @@ print.bayesfactor_parameters <- function(x, digits = 3, log = FALSE, ...) { cat(paste0(colnames(formatted_table), ": ")) } cat(formatted_table[1, 1]) + cat("\n") } else { # print for data frame diff --git a/tests/testthat/test-hdi.R b/tests/testthat/test-hdi.R index a649a9d62..d74ac27ca 100644 --- a/tests/testthat/test-hdi.R +++ b/tests/testthat/test-hdi.R @@ -6,18 +6,17 @@ test_that("hdi", { skip_if_not_or_load_if_installed("httr") skip_if_not_or_load_if_installed("BayesFactor") - expect_equal(hdi(distribution_normal(1000), ci = .90)$CI_low[1], -1.64, tolerance = 0.02) - expect_equal(nrow(hdi(distribution_normal(1000), ci = c(.80, .90, .95))), 3, tolerance = 0.01) + expect_equal(hdi(distribution_normal(1000), ci = 0.90)$CI_low[1], -1.64, tolerance = 0.02) + expect_equal(nrow(hdi(distribution_normal(1000), ci = c(0.80, 0.90, 0.95))), 3, tolerance = 0.01) expect_equal(hdi(distribution_normal(1000), ci = 1)$CI_low[1], -3.29, tolerance = 0.02) - expect_equal(nchar(capture.output(print(hdi(distribution_normal(1000))))), 22) - expect_equal(length(capture.output(print(hdi(distribution_normal(1000), ci = c(.80, .90))))), 5) + expect_identical(nchar(capture.output(print(hdi(distribution_normal(1000))))), 22L) + expect_length(capture.output(print(hdi(distribution_normal(1000), ci = c(0.80, 0.90)))), 5) - - expect_warning(hdi(c(2, 3, NA))) - expect_warning(hdi(c(2, 3))) - expect_warning(hdi(distribution_normal(1000), ci = 0.0000001)) - expect_warning(hdi(distribution_normal(1000), ci = 950)) - expect_warning(hdi(c(0, 0, 0))) + expect_message(hdi(c(2, 3, NA))) + expect_message(hdi(c(2, 3))) + expect_message(hdi(distribution_normal(1000), ci = 0.0000001)) + expect_message(hdi(distribution_normal(1000), ci = 950)) + expect_message(hdi(c(0, 0, 0))) }) @@ -65,7 +64,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(