Skip to content

Commit

Permalink
lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Nov 4, 2024
1 parent 6cc35cb commit dbcd64a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/testthat/test-get_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ test_that("retrieve from same environment", {
test_that("retrieve from correct environment", {
foo <- function() {
foo <- data.frame(x = 1:10, y = 2:11)

return(lm(y ~ x, data = foo))
lm(y ~ x, data = foo)
}

# There should be no warning about "Could not recover model data from
Expand All @@ -32,8 +31,7 @@ test_that("fetch from local, not global, environment", {

foo <- function() {
mtcars$cylinders <- factor(mtcars$cyl)

return(lm(mpg ~ cylinders + disp, data = mtcars))
lm(mpg ~ cylinders + disp, data = mtcars)
}

expect_setequal(
Expand All @@ -54,7 +52,7 @@ test_that("retrieve from call formula environment", {
# find_formula(fit)$conditional happens to not have an environment for tobit
# models, so get_data() should check environment(get_call(fit)$formula). See
# #666
return(AER::tobit(y ~ x, data = d, right = 1.5))
AER::tobit(y ~ x, data = d, right = 1.5)
}

expect_setequal(
Expand Down Expand Up @@ -222,7 +220,7 @@ test_that("mgcv", {
# fall back to the model frame. See
# https://github.com/cran/mgcv/blob/a4e69cf44a49c84a41a42e90c86995a843733968/R/mgcv.r#L2156-L2159
d <- iris
d$NewFac <- rep(c(1, 2), length.out = 150)
d$NewFac <- rep_len(c(1, 2), 150)
model <- mgcv::gam(Sepal.Length ~ s(Petal.Length, by = interaction(Species, NewFac)), data = d)

# There should be two warnings: One for failing to get the data from the
Expand Down Expand Up @@ -461,7 +459,7 @@ test_that("get_data works for fixest inside functions", {
fixest_wrapper1 <- function(data) {
data$cylinders <- factor(data$cyl)
fit <- fixest::feglm(mpg ~ cylinders * disp + hp, data = data)
return(fit)
fit
}
global_fixest1 <- fixest_wrapper1(data = mtcars)
data <- mtcars[, c("mpg", "disp")]
Expand All @@ -474,7 +472,7 @@ test_that("get_data works for fixest inside functions", {
fixest_wrapper2 <- function(data) {
data$cylinders <- factor(data$cyl)
fit <- fixest::feglm(mpg ~ cylinders * disp + hp, data = data)
return(fit)
fit
}
data <- mtcars
global_fixest2 <- fixest_wrapper2(data = data[1:20, ])
Expand Down

0 comments on commit dbcd64a

Please sign in to comment.