From c9c438a05c94d0ef2653b5d6fe507748ab25bc12 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Fri, 26 Jul 2024 20:16:42 +0200 Subject: [PATCH] fix a few lints Thanks `{flint}` --- tests/testthat/test-bayesfactor_parameters.R | 10 +++++----- tests/testthat/test-bayesfactor_restricted.R | 6 +++--- tests/testthat/test-brms.R | 2 +- tests/testthat/test-effective_sample.R | 6 +++--- tests/testthat/test-emmGrid.R | 2 +- tests/testthat/test-rstanarm.R | 2 +- tests/testthat/test-spi.R | 8 ++++---- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/testthat/test-bayesfactor_parameters.R b/tests/testthat/test-bayesfactor_parameters.R index 8c3322f5c..ff821f432 100644 --- a/tests/testthat/test-bayesfactor_parameters.R +++ b/tests/testthat/test-bayesfactor_parameters.R @@ -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) }) diff --git a/tests/testthat/test-bayesfactor_restricted.R b/tests/testthat/test-bayesfactor_restricted.R index 6b338c1b2..9a7727758 100644 --- a/tests/testthat/test-bayesfactor_restricted.R +++ b/tests/testthat/test-bayesfactor_restricted.R @@ -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( diff --git a/tests/testthat/test-brms.R b/tests/testthat/test-brms.R index d900848d0..28c517b17 100644 --- a/tests/testthat/test-brms.R +++ b/tests/testthat/test-brms.R @@ -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") diff --git a/tests/testthat/test-effective_sample.R b/tests/testthat/test-effective_sample.R index 180e522ba..bdecc3138 100644 --- a/tests/testthat/test-effective_sample.R +++ b/tests/testthat/test-effective_sample.R @@ -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 ) ) @@ -22,7 +22,7 @@ test_that("effective_sample", { data.frame( Parameter = c("b_Intercept"), ESS = c(2888), - stringsAsFactors = F + stringsAsFactors = FALSE ) ) @@ -33,7 +33,7 @@ test_that("effective_sample", { data.frame( Parameter = c("b_Intercept"), ESS = c(1059), - stringsAsFactors = F + stringsAsFactors = FALSE ) ) }) diff --git a/tests/testthat/test-emmGrid.R b/tests/testthat/test-emmGrid.R index e7b76322e..b5fff9968 100644 --- a/tests/testthat/test-emmGrid.R +++ b/tests/testthat/test-emmGrid.R @@ -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) }) diff --git a/tests/testthat/test-rstanarm.R b/tests/testthat/test-rstanarm.R index 9faed14d2..75546cc27 100644 --- a/tests/testthat/test-rstanarm.R +++ b/tests/testthat/test-rstanarm.R @@ -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") diff --git a/tests/testthat/test-spi.R b/tests/testthat/test-spi.R index 118611210..41d377106 100644 --- a/tests/testthat/test-spi.R +++ b/tests/testthat/test-spi.R @@ -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))) @@ -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(