Skip to content

Commit

Permalink
clean a few lints related to expect_equal()
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Apr 3, 2023
1 parent ca89c4a commit ff67ea3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 37 deletions.
12 changes: 8 additions & 4 deletions tests/testthat/test-Hmisc.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ test_that("issue 697", {
suppressWarnings(
mod <- Hmisc::fit.mult.impute(
y ~ x1 + x2,
fitter = rms::orm, xtrans = imputer, data = df, pr = FALSE
fitter = rms::orm,
xtrans = imputer,
data = df,
pr = FALSE
)
)

expect_s3_class(parameters(mod), "parameters_model")
expect_s3_class(standard_error(mod), "data.frame")
expect_s3_class(p_value(mod), "data.frame")
expect_equal(nrow(parameters(mod)), 3L)
expect_equal(nrow(standard_error(mod)), 3L)
expect_equal(nrow(p_value(mod)), 3L)

expect_identical(nrow(parameters(mod)), 3L)
expect_identical(nrow(standard_error(mod)), 3L)
expect_identical(nrow(p_value(mod)), 3L)
})
54 changes: 23 additions & 31 deletions tests/testthat/test-dominance_analysis.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
skip_if_not_installed("performance")
skip_if_not_installed("domir")
skip_if_not(getRversion() >= "3.6.0")

DA_test_model <- lm(mpg ~ vs + cyl + carb, data = mtcars)

Expand All @@ -14,10 +13,7 @@ test_that("dominance_analysis$general_dominance", {

gnrl_da <- DA_performance$General$General_Dominance

expect_equal(
gnrl_domir,
gnrl_da
)
expect_identical(gnrl_domir, gnrl_da)
})

test_that("dominance_analysis$conditional_dominance", {
Expand All @@ -27,10 +23,7 @@ test_that("dominance_analysis$conditional_dominance", {
cdl_da <- as.matrix(DA_performance$Conditional[, -1])
dimnames(cdl_da) <- c(NULL, NULL)

expect_equal(
cdl_domir,
cdl_da
)
expect_identical(cdl_domir, cdl_da)
})

test_that("dominance_analysis$complete_dominance", {
Expand All @@ -40,28 +33,33 @@ test_that("dominance_analysis$complete_dominance", {
cpt_da <- t(DA_performance$Complete[, -1])
dimnames(cpt_da) <- list(NULL, NULL)

expect_equal(
cpt_domir,
cpt_da
)
expect_identical(cpt_domir, cpt_da)
})

DA_performance2 <-
dominance_analysis(DA_test_model,
all = ~vs, sets = c(~carb),
complete = FALSE, conditional = FALSE
)
DA_domir2 <-
domir::domin(mpg ~ cyl, lm, list(performance::r2, "R2"),
all = "vs", sets = list("carb"), data = mtcars,
complete = FALSE, conditional = FALSE
)
DA_performance2 <- dominance_analysis(
DA_test_model,
all = ~vs,
sets = c(~carb),
complete = FALSE,
conditional = FALSE
)

DA_domir2 <- domir::domin(
mpg ~ cyl,
lm,
list(performance::r2, "R2"),
all = "vs",
sets = list("carb"),
data = mtcars,
complete = FALSE,
conditional = FALSE
)

test_that("dominance_analysis$general_dominance with sets/all", {
domir_all_sub_r2 <- DA_domir2$Fit_Statistic_All_Subsets
names(domir_all_sub_r2) <- NULL

expect_equal(
expect_identical(
domir_all_sub_r2,
with(DA_performance2$General, General_Dominance[Subset == "all"])
)
Expand All @@ -73,15 +71,9 @@ test_that("dominance_analysis$general_dominance with sets/all", {
DA_performance2$General$General_Dominance,
list(DA_performance2$General$Subset), mean
)

gnrl_da2 <- gnrl_da2[which(gnrl_da2$Group.1 %in% c("cyl", "set1")), ]

gnrl_da2 <- gnrl_da2$x

names(gnrl_da2) <- NULL

expect_equal(
gnrl_domir2,
gnrl_da2
)
expect_identical(gnrl_domir2, gnrl_da2)
})
4 changes: 2 additions & 2 deletions tests/testthat/test-emmGrid-df_colname.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ emm2 <- emmeans::emmeans(m2, ~group, df = NA)
es2 <- emmeans::eff_size(emm2, sigma = sigma(m2), edf = df.residual(m2))

test_that("df", {
expect_equal(
expect_identical(
colnames(model_parameters(es1)),
c(
"contrast", "Coefficient", "SE", "CI", "CI_low", "CI_high",
"t", "df_error", "p"
)
)

expect_equal(
expect_identical(
colnames(model_parameters(es2)),
c(
"contrast", "Coefficient", "SE", "CI", "CI_low", "CI_high",
Expand Down

0 comments on commit ff67ea3

Please sign in to comment.