Skip to content

Commit

Permalink
Get rid of numeric_leading_zero_linter() lints
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Dec 28, 2022
1 parent e425d75 commit 9494db7
Show file tree
Hide file tree
Showing 84 changed files with 166 additions and 159 deletions.
2 changes: 1 addition & 1 deletion R/compute_variances.R
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@
# we here check if random slopes from correlated and uncorrelated
# are duplicated (i.e. their difference is 0 - including a tolerance)
# and then remove duplicated elements
the_same <- which(abs(outer(out[j], rndslopes, `-`)) < .0001)
the_same <- which(abs(outer(out[j], rndslopes, `-`)) < 0.0001)
if (length(the_same) && grepl(dn[the_same], names(out[j]), fixed = TRUE)) {
to_remove <- c(to_remove, j)
}
Expand Down
2 changes: 1 addition & 1 deletion R/get_loglikelihood.R
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ get_loglikelihood.cpglm <- get_loglikelihood.plm
} else if (trans == "expm1") {
.weighted_sum((get_response(x, as_proportion = TRUE) - 1), w = model_weights)
} else if (trans == "sqrt") {
.weighted_sum(log(.5 / sqrt(get_response(x, as_proportion = TRUE))), w = model_weights)
.weighted_sum(log(0.5 / sqrt(get_response(x, as_proportion = TRUE))), w = model_weights)
} else if (is.null(model_weights)) {
.ll_log_adjustment(x)
} else {
Expand Down
2 changes: 1 addition & 1 deletion R/get_statistic.R
Original file line number Diff line number Diff line change
Expand Up @@ -2304,7 +2304,7 @@ get_statistic.metaplus <- function(x, ...) {
ci_low <- as.vector(x$results[, "95% ci.lb"])
ci_high <- as.vector(x$results[, "95% ci.ub"])
cis <- apply(cbind(ci_low, ci_high), MARGIN = 1, diff)
se <- cis / (2 * stats::qnorm(.975))
se <- cis / (2 * stats::qnorm(0.975))

out <- data.frame(
Parameter = params$Parameter,
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-BayesFactorBF.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test_that("find_parameters", {
expect_equal(find_parameters(t2d)[[1]], "Difference")
})

t <- c(-.15, 2.39, 2.42, 2.43)
t <- c(-0.15, 2.39, 2.42, 2.43)
N <- c(100, 150, 97, 99)
x <- meta.ttestBF(t = t, n1 = N, rscale = 1)
test_that("get_data", {
Expand Down Expand Up @@ -303,9 +303,9 @@ ttest_BFk <- ttestBF(sleep$extra[sleep$group == 1], sleep$extra[sleep$group == 2
nullInterval = c(-3, 0)
)

prop_BF1 <- proportionBF(y = 15, N = 25, p = .5, progress = FALSE)
prop_BF1 <- proportionBF(y = 15, N = 25, p = 0.5, progress = FALSE)
prop_BFk <- proportionBF(
y = 15, N = 25, p = .5, progress = FALSE,
y = 15, N = 25, p = 0.5, progress = FALSE,
nullInterval = c(0, 0.3)
)

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-GLMMadaptive.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ if (.runThisTest) {
})

test_that("link_inverse", {
expect_identical(link_inverse(m)(.2), exp(.2))
expect_identical(link_inverse(m)(0.2), exp(0.2))
})

test_that("clean_names", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-Gam2.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (.runThisTest &&
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), plogis(.2), tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), plogis(0.2), tolerance = 1e-5)
})

test_that("get_data", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-LORgee.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if (requiet("multgee")) {
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), plogis(.2), tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), plogis(0.2), tolerance = 1e-5)
})

test_that("get_data", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-MCMCglmm.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if (.Platform$OS.type == "windows" &&
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.5), .5, tolerance = 1e-1)
expect_equal(link_inverse(m1)(0.5), 0.5, tolerance = 1e-1)
})

test_that("get_data", {
Expand Down Expand Up @@ -84,7 +84,7 @@ if (.Platform$OS.type == "windows" &&
})

test_that("linkfun", {
expect_equal(link_function(m1)(.5), .5, tolerance = 1e-1)
expect_equal(link_function(m1)(0.5), 0.5, tolerance = 1e-1)
})

test_that("find_parameters", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-aovlist.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ test_that("get_predictors", {
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), .2, tolerance = 1e-5)
expect_equal(link_inverse(m2)(.2), .2, tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), 0.2, tolerance = 1e-5)
expect_equal(link_inverse(m2)(0.2), 0.2, tolerance = 1e-5)
})

test_that("get_data", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-betabin.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ if (requiet("aod")) {
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), plogis(.2), tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), plogis(0.2), tolerance = 1e-5)
})

test_that("link_function", {
expect_equal(link_function(m1)(.2), qlogis(.2), tolerance = 1e-5)
expect_equal(link_function(m1)(0.2), qlogis(0.2), tolerance = 1e-5)
})

test_that("get_data", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-betareg.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (
})

test_that("link_inverse", {
expect_identical(link_inverse(m1)(.2), plogis(.2))
expect_identical(link_inverse(m1)(0.2), plogis(0.2))
})

test_that("get_data", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-bigglm.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if (.runThisTest && requiet("glmmTMB") && requiet("biglm")) {
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), exp(.2), tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), exp(0.2), tolerance = 1e-5)
})

test_that("get_data", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-blmer.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ if (requiet("blme")) {
})

test_that("link_inverse", {
expect_identical(link_inverse(m1)(.2), .2)
expect_identical(link_inverse(m2)(.2), .2)
expect_identical(link_inverse(m1)(0.2), 0.2)
expect_identical(link_inverse(m2)(0.2), 0.2)
})

test_that("get_data", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-censReg.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if (requiet("censReg") && requiet("AER")) {
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), .2, tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), 0.2, tolerance = 1e-5)
})

test_that("get_data", {
Expand Down
6 changes: 2 additions & 4 deletions tests/testthat/test-clm.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if (

requiet("ordinal")) {
if (requiet("ordinal")) {
data(wine, package = "ordinal")
m1 <- clm(rating ~ temp * contact, data = wine)

Expand Down Expand Up @@ -37,7 +35,7 @@ if (
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), plogis(.2), tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), plogis(0.2), tolerance = 1e-5)
})

test_that("get_data", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-clm2.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if (
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), plogis(.2), tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), plogis(0.2), tolerance = 1e-5)
})

test_that("find_weights", {
Expand Down
10 changes: 3 additions & 7 deletions tests/testthat/test-clmm.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ osx <- tryCatch(

.runThisTest <- Sys.getenv("RunAllinsightTests") == "yes"

if (.runThisTest &&


requiet("lme4") &&
requiet("ordinal")) {
if (.runThisTest && requiet("lme4") && requiet("ordinal")) {
data(wine, package = "ordinal")
data(soup)

Expand Down Expand Up @@ -92,8 +88,8 @@ if (.runThisTest &&
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), plogis(.2), tolerance = 1e-5)
expect_equal(link_inverse(m2)(.2), pnorm(.2), tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), plogis(0.2), tolerance = 1e-5)
expect_equal(link_inverse(m2)(0.2), pnorm(0.2), tolerance = 1e-5)
})

test_that("get_data", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-coxme.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ if (
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), plogis(.2), tolerance = 1e-5)
expect_equal(link_inverse(m2)(.2), plogis(.2), tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), plogis(0.2), tolerance = 1e-5)
expect_equal(link_inverse(m2)(0.2), plogis(0.2), tolerance = 1e-5)
})

test_that("get_data", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-coxph.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test_that("find_response", {
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), plogis(.2), tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), plogis(0.2), tolerance = 1e-5)
})

test_that("get_data", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-cpglmm.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ if (


test_that("link_function", {
expect_equal(link_function(m1)(.2), log(.2), tolerance = 1e-3)
expect_equal(link_function(m1)(0.2), log(0.2), tolerance = 1e-3)
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), exp(.2), tolerance = 1e-3)
expect_equal(link_inverse(m1)(0.2), exp(0.2), tolerance = 1e-3)
})


Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-crch.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), .2, tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), 0.2, tolerance = 1e-5)
})

test_that("get_data", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-crq.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ if (requiet("quantreg")) {
})

test_that("link_function", {
expect_equal(link_function(m1)(.2), .2, tolerance = 1e-5)
expect_equal(link_function(m1)(0.2), 0.2, tolerance = 1e-5)
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), .2, tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), 0.2, tolerance = 1e-5)
})

test_that("find_parameters", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-feis.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if (!osx && requiet("plm") && requiet("feisr")) {
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), .2, tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), 0.2, tolerance = 1e-5)
})

test_that("get_data", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-felm.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ if (
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), .2, tolerance = 1e-5)
expect_equal(link_inverse(m1)(0.2), 0.2, tolerance = 1e-5)
})

test_that("get_data", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-find_predictor_nested_re.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if (requiet("lme4")) {
set.seed(1984)
dat <- data.frame(
y = rnorm(1000 * 5, sd = 1 - .20),
y = rnorm(1000 * 5, sd = 1 - 0.20),
time = rep(1:10, 100 * 5),
g1 = sort(rep(1:100, 10 * 5)),
g2 = sort(rep(1:10, 100 * 5))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-find_terms.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (requiet("lme4")) {

set.seed(1984)
dat <- data.frame(
y = rnorm(100 * 5, sd = 1 - .20),
y = rnorm(100 * 5, sd = 1 - 0.20),
time = rep(1:10, 10 * 5),
g1 = sort(rep(1:100, 5)),
g2 = sort(rep(1:10, 10 * 5))
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-find_weights.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
if (requiet("lme4")) {
test_that("find_weights", {
data(mtcars)
mtcars$weight <- rnorm(nrow(mtcars), 1, .3)
mtcars$weight <- rnorm(nrow(mtcars), 1, 0.3)
m <- lm(mpg ~ wt + cyl + vs, data = mtcars, weights = weight)
expect_equal(find_weights(m), "weight")
})
test_that("find_weights", {
data(iris)
iris$wgt <- rnorm(nrow(iris), 1, .3)
iris$wgt <- rnorm(nrow(iris), 1, 0.3)
m <- lmer(Sepal.Width ~ Sepal.Length + (1 | Species), data = iris, weights = wgt)
expect_equal(find_weights(m), "wgt")
})
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/test-fixest.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ test_that("get_predictors", {
})

test_that("link_inverse", {
expect_equal(link_inverse(m1)(.2), exp(.2), tolerance = 1e-4)
expect_equal(link_inverse(m2)(.2), .2, tolerance = 1e-4)
expect_equal(link_inverse(m3)(.2), exp(.2), tolerance = 1e-4)
expect_equal(link_inverse(m1)(0.2), exp(0.2), tolerance = 1e-4)
expect_equal(link_inverse(m2)(0.2), 0.2, tolerance = 1e-4)
expect_equal(link_inverse(m3)(0.2), exp(0.2), tolerance = 1e-4)
})

test_that("link_function", {
expect_equal(link_function(m1)(.2), log(.2), tolerance = 1e-4)
expect_equal(link_function(m2)(.2), .2, tolerance = 1e-4)
expect_equal(link_function(m3)(.2), log(.2), tolerance = 1e-4)
expect_equal(link_function(m1)(0.2), log(0.2), tolerance = 1e-4)
expect_equal(link_function(m2)(0.2), 0.2, tolerance = 1e-4)
expect_equal(link_function(m3)(0.2), log(0.2), tolerance = 1e-4)
})

test_that("get_data", {
Expand Down Expand Up @@ -264,14 +264,14 @@ test_that("get_predicted", {
b <- get_predicted(m1, type = "link", predict = NULL)
expect_equal(a, b)
# these used to raise warnings
expect_warning(get_predicted(m1, ci = .4), NA)
expect_warning(get_predicted(m1, ci = 0.4), NA)
expect_warning(get_predicted(m1, predict = NULL, type = "link"), NA)
})

test_that("get_data works when model data has name of reserved words", {
## NOTE check back every now and then and see if tests still work
skip("works interactively")
rep <- data.frame(Y = runif(100) > .5, X = rnorm(100))
rep <- data.frame(Y = runif(100) > 0.5, X = rnorm(100))
m <- feglm(Y ~ X, data = rep, family = binomial)
out <- get_data(m)
expect_s3_class(out, "data.frame")
Expand Down

0 comments on commit 9494db7

Please sign in to comment.