Skip to content

Commit

Permalink
Fix for Issue #266
Browse files Browse the repository at this point in the history
tests: added test to maintain coverage
  • Loading branch information
Max-Bladen committed Nov 15, 2022
1 parent bebb93c commit f921873
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/testthat/test-auroc.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,27 @@ test_that("auroc works", {
rbind(0.9981, 7.124e-09))

})



test_that("Safely handles zero var (non-zero center) features", {

X1 <- data.frame(matrix(rnorm(100000, 5, 5), nrow = 100))
X2 <- data.frame(matrix(rnorm(150000, 5, 5), nrow = 100))
Y <- c(rep("A", 50), rep("B", 50))

X <- list(block1=X1, block2=X2)

list.keepX <- list(block1=c(15, 15), block2=c(30,30))

X$block1[,1] <- rep(1, 100)
model = suppressWarnings(block.splsda(X = X, Y = Y, ncomp = 2,
keepX = list.keepX, design = "full"))

set.seed(9425)
auc.splsda = .quiet(auroc(model))

.expect_numerically_close(auc.splsda$block1$comp1[[1]], 0.815)
.expect_numerically_close(auc.splsda$block2$comp2[[2]], 2.22e-16)

})

0 comments on commit f921873

Please sign in to comment.