Skip to content

Commit

Permalink
Untracked: fix tests to export warnings about sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
chschan committed Apr 21, 2023
1 parent b1a0f89 commit e3169be
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
7 changes: 4 additions & 3 deletions tests/testthat/test-preparedata-tidytable.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ test_that("Select Rows",
expect_warning(res <- PrepareData("Column", input.data.table = tabWithN, select.rows = "30 to 34, 35 to 39"), "Multiple statistics detected")
expect_equal(rownames(res$data), c("30 to 34", "35 to 39"))

res <- PrepareData("Table", input.data.table = LifeCycleSavings, first.k.rows = 10,
sort.rows = TRUE, reverse.rows = TRUE, reverse.columns = TRUE)
expect_warning(res <- PrepareData("Table", input.data.table = LifeCycleSavings, first.k.rows = 10,
sort.rows = TRUE, reverse.rows = TRUE, reverse.columns = TRUE))
expect_equal(colnames(res$data), rev(colnames(LifeCycleSavings)))
expect_equal(rownames(res$data), c("Libya", "Jamaica", "Japan", "Malta", "Netherlands",
"Portugal", "China", "Greece", "Korea", "Zambia"))
Expand All @@ -121,7 +121,8 @@ test_that("Select Rows",

test_that("Sorting rows",
{
expect_silent(res0 <- PrepareData("Table", input.data.table = tabWithN, tidy = FALSE, sort.rows = TRUE))
expect_warning(res0 <- PrepareData("Table", input.data.table = tabWithN, tidy = FALSE,
sort.rows = TRUE), "Table has been sorted on column 8")
expect_equal(dim(res0$data), c(9,8,3))

expect_warning(res1 <- PrepareData("Column", input.data.table = tabWithN, tidy = TRUE, sort.rows = TRUE),
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-preparedata.R
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ test_that("as.percentages from pasted data and raw data work by dividing by nrow
zz = PrepareData("Venn", input.data.raw = list(z), as.percentages = TRUE, first.aggregate = FALSE)
expect_equal(zz$data[1,1], 1)
zz = PrepareData("Venn", input.data.pasted = list(z), as.percentages = TRUE, first.aggregate = FALSE)
expect_equal(zz$data[1,1], c(A = 1))
expect_equal(zz$data[1,1], 1)
z = matrix(c(1,1,1,1,1,0,1,0,0),3, dimnames = list(1:3, LETTERS[1:3]))
zz = suppressWarnings(PrepareData("Column", input.data.raw = list(z), as.percentages = TRUE,
first.aggregate = FALSE))
Expand Down
9 changes: 5 additions & 4 deletions tests/testthat/test-stattesting.R
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,16 @@ test_that("QStatisticsTestingInfo rearranges with data manipulations",

orig.pcorr <- structure(attr(tb.2d, "QStatisticsTestingInfo")$pcorrected,
names = paste(rep(colnames(tb.2d), nrow(tb.2d)), "-", rep(rownames(tb.2d), each=ncol(tb.2d))))
expect_error(res <- PrepareData("Column", input.data.table = tb.2d, signif.symbol = "Caret",
tidy = FALSE, hide.empty.rows.and.columns = TRUE, sort.rows = TRUE, signif.append = TRUE), NA)
expect_warning(res <- PrepareData("Column", input.data.table = tb.2d, signif.symbol = "Caret",
tidy = FALSE, hide.empty.rows.and.columns = TRUE, sort.rows = TRUE, signif.append = TRUE),
"Table has been sorted")
new.pcorr <- structure(attr(res$data, "QStatisticsTestingInfo")$pcorrected,
names = paste(rep(colnames(res$data), nrow(res$data)), "-", rep(rownames(res$data), each=ncol(res$data))))
expect_equal(orig.pcorr[names(new.pcorr)], new.pcorr)

expect_error(res <- PrepareData("Column", input.data.table = tb.2d, signif.symbol = "Caret",
expect_warning(res <- PrepareData("Column", input.data.table = tb.2d, signif.symbol = "Caret",
tidy = FALSE, hide.empty.rows.and.columns = TRUE, sort.columns = TRUE, transpose = TRUE,
signif.append = TRUE), NA)
signif.append = TRUE), "Table has been sorted")
new.pcorr <- structure(attr(res$data, "QStatisticsTestingInfo")$pcorrected,
names = paste(rep(rownames(res$data), each=ncol(res$data)), "-", rep(colnames(res$data), nrow(res$data))))
expect_equal(orig.pcorr[names(new.pcorr)], new.pcorr)
Expand Down

0 comments on commit e3169be

Please sign in to comment.