From 73966e5e4a5281083e73434824abd57ea5751834 Mon Sep 17 00:00:00 2001 From: Yixuan Qiu Date: Fri, 19 Jun 2026 23:11:51 +0800 Subject: [PATCH] use compatible tolerance --- tests/testthat/test-4-pcadapt.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-4-pcadapt.R b/tests/testthat/test-4-pcadapt.R index c412d71..6215952 100644 --- a/tests/testthat/test-4-pcadapt.R +++ b/tests/testthat/test-4-pcadapt.R @@ -22,18 +22,18 @@ test_that("Same as pcadapt", { row.names = FALSE, col.names = FALSE) expect_output(bed <- pcadapt::read.pcadapt(tmpfile, type = "pcadapt")) - obj.pcadapt <- pcadapt::pcadapt(bed, K = 10, min.maf = 0) + obj.pcadapt <- pcadapt::pcadapt(bed, K = 10, min.maf = 0, tol = 1e-6) ################################################################################ - obj.svd <- big_randomSVD(G, snp_scaleBinom()) + obj.svd <- big_randomSVD(G, snp_scaleBinom(), tol = 1e-6) test <- bigsnpr:::multLinReg(G, rows_along(G), cols_along(G), obj.svd$u, 1) expect_equal(obj.svd$center / 2, obj.pcadapt$af) # TODO: change this test when new version of {pcadapt} on CRAN # expect_equal(obj.svd$d, obj.pcadapt$singular.values * sqrt((nrow(G) - 1) * ncol(G))) - expect_equal(abs(obj.svd$u), abs(obj.pcadapt$scores)) - expect_equal(abs(obj.svd$v), abs(obj.pcadapt$loadings)) + expect_equal(abs(obj.svd$u), abs(obj.pcadapt$scores), tolerance = 1e-5) + expect_equal(abs(obj.svd$v), abs(obj.pcadapt$loadings), tolerance = 1e-5) expect_equal(test, obj.pcadapt$zscores, tolerance = 0.2) ################################################################################