Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattansb committed Jan 8, 2025
1 parent fc28e24 commit f95c504
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions R/methods_aov.R
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,12 @@ model_parameters.seqanova.svyglm <- model_parameters.aov
.anova_table_wide <- function(data, ...) {
wide_anova <- function(x) {
# creating numerator and denominator degrees of freedom
idxResid <- x$Parameter == "Residuals"
if (length(idxResid) >= 1L && any(idxResid)) {
idxResid <- which(x$Parameter == "Residuals")
if (length(idxResid)) {
x$df_error <- x$df[idxResid]
x$Sum_Squares_Error <- x$Sum_Squares[idxResid]
x$Mean_Square_Error <- x$Mean_Square[idxResid]
x <- x[!idxResid, ]
x <- x[-idxResid, ]
}
x
}
Expand Down
12 changes: 10 additions & 2 deletions tests/testthat/test-model_parameters.aov.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ test_that("model_parameters.aov - table_wide", {
out1 <- model_parameters(mod1, table_wide = FALSE)
out2 <- model_parameters(mod1, table_wide = TRUE)

expect_true(all(out2$Mean_Square_Error %in% out1$Mean_Square[out1$Parameter == "Residuals"]))
expect_true(all(out1$Mean_Square[out1$Parameter == "Residuals"] %in% out2$Mean_Square_Error))
idx <- which(out1$Parameter == "Residuals")

expect_true(all(out2$Sum_Squares_Error %in% out1$Sum_Squares[idx]))
expect_true(all(out1$Sum_Squares[idx] %in% out2$Sum_Squares_Error))

expect_true(all(out2$Mean_Square_Error %in% out1$Mean_Square[idx]))
expect_true(all(out1$Mean_Square[idx] %in% out2$Mean_Square_Error))

expect_true(all(out2$df_error %in% out1$df[idx]))
expect_true(all(out1$df[idx] %in% out2$df_error))
})

0 comments on commit f95c504

Please sign in to comment.