Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DominiqueMakowski committed Dec 1, 2024
1 parent 0f29129 commit ce7b972
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/cor_sort.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,7 @@ cor_sort.matrix <- function(x, distance = "correlation", hclust_method = "comple
# Append any unused rows at the end
refined_row_order <- c(refined_row_order, which(!used_rows))

list(row_order = rownames(m)[refined_row_order], col_order = colnames(m)[col_order])
# Apply
m <- clustered_matrix[refined_row_order, ]
list(row_order = rownames(m), col_order = colnames(m))
}
5 changes: 5 additions & 0 deletions tests/testthat/test-cor_sort.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
test_that("cor_sort", {
r <- cor(mtcars)
expect_equal(as.numeric(diag(r)), rep(1, ncol(mtcars)))

Check warning on line 3 in tests/testthat/test-cor_sort.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-cor_sort.R,line=3,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
# heatmap(r, Rowv = NA, Colv = NA)

r1 <- cor_sort(r)
expect_equal(as.numeric(diag(r)), rep(1, ncol(mtcars)))

Check warning on line 7 in tests/testthat/test-cor_sort.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-cor_sort.R,line=7,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
# heatmap(r1, Rowv = NA, Colv = NA)

r2 <- cor(mtcars[names(mtcars)[1:5]], mtcars[names(mtcars)[6:11]])
expect_equal(rownames(r2), names(mtcars)[1:5])

Check warning on line 11 in tests/testthat/test-cor_sort.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-cor_sort.R,line=11,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
# heatmap(r2, Rowv = NA, Colv = NA)

r3 <- cor_sort(r2)
expect_equal(all(rownames(r3) == names(mtcars)[1:5]), FALSE)

Check warning on line 15 in tests/testthat/test-cor_sort.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-cor_sort.R,line=15,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.

Check warning on line 15 in tests/testthat/test-cor_sort.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-cor_sort.R,line=15,col=3,[expect_true_false_linter] expect_false(x) is better than expect_equal(x, FALSE)
# heatmap(r3, Rowv = NA, Colv = NA)
})

Check warning on line 17 in tests/testthat/test-cor_sort.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=tests/testthat/test-cor_sort.R,line=17,col=3,[trailing_blank_lines_linter] Add a terminal newline.

0 comments on commit ce7b972

Please sign in to comment.