Skip to content

Commit

Permalink
lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Dec 15, 2024
1 parent ab46de3 commit 69083c7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/testthat/test-estimate_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ test_that("estimate_means() - lm", {
# At specific levels of continuous
estim1 <- suppressMessages(estimate_means(model, by = "Sepal.Width"))
estim2 <- suppressMessages(estimate_means(model, by = "Sepal.Width", backend = "marginaleffects"))
expect_equal(dim(estim1), c(10, 5))
expect_equal(dim(estim2), c(10, 5))
expect_identical(dim(estim1), c(10L, 5L))
expect_identical(dim(estim2), c(10L, 5L))
# Note that the absolute values are different here... for unclear reasons
expect_true(max(diff(estim1$Mean) - diff(estim2$Mean)) < 1e-10)

Check warning on line 71 in tests/testthat/test-estimate_means.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-estimate_means.R,line=71,col=3,[expect_comparison_linter] expect_lt(x, y) is better than expect_true(x < y).
expect_equal(estim1$Mean, estim2$Mean, tolerance = 1e-4)
Expand All @@ -81,8 +81,8 @@ test_that("estimate_means() - lm", {

estim1 <- suppressMessages(estimate_means(model, by = "all"))
estim2 <- suppressMessages(estimate_means(model, by = "all", backend = "marginaleffects"))
expect_equal(dim(estim1), c(30, 6))
expect_equal(dim(estim2), c(30, 6))
expect_identical(dim(estim1), c(30L, 6L))
expect_identical(dim(estim2), c(30L, 6L))
expect_equal(estim1$Mean[order(estim1$Sepal.Width)], estim2$Mean, tolerance = 1e-4)
expect_equal(estim1$CI_low[order(estim1$Sepal.Width)], estim2$CI_low, tolerance = 1e-3)

Expand Down Expand Up @@ -164,11 +164,11 @@ test_that("estimate_means() - lm", {
model <- lm(mpg ~ gear * vs * am, data = dat)

estim <- suppressMessages(estimate_means(model))
expect_equal(dim(estim), c(12, 7))
expect_identical(dim(estim), c(12L, 7L))
estim <- suppressMessages(estimate_means(model, fixed = "am"))
expect_equal(dim(estim), c(6, 7))
expect_identical(dim(estim), c(6L, 7L))
estim <- suppressMessages(estimate_means(model, by = c("gear='5'", "vs")))
expect_equal(dim(estim), c(2, 7))
expect_identical(dim(estim), c(2L, 7L))

dat <- iris
dat$factor1 <- ifelse(dat$Sepal.Width > 3, "A", "B")
Expand All @@ -178,9 +178,9 @@ test_that("estimate_means() - lm", {

model <- lm(Petal.Width ~ factor1 * factor2 * factor3, data = dat)
estim <- suppressMessages(estimate_means(model))
expect_equal(dim(estim), c(8, 7))
expect_identical(dim(estim), c(8L, 7L))
estim <- suppressMessages(estimate_means(model, fixed = "factor3"))
expect_equal(dim(estim), c(4, 7))
expect_identical(dim(estim), c(4L, 7L))
})


Expand Down

0 comments on commit 69083c7

Please sign in to comment.