From 98675d0186f2fa7f016543a9f454c3578a5260ef Mon Sep 17 00:00:00 2001 From: immanuelazn Date: Thu, 12 Dec 2024 15:13:11 -0800 Subject: [PATCH] [r] fix normalization tests --- r/tests/testthat/test-matrix_transforms.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/r/tests/testthat/test-matrix_transforms.R b/r/tests/testthat/test-matrix_transforms.R index b1941f8b..06bc3337 100644 --- a/r/tests/testthat/test-matrix_transforms.R +++ b/r/tests/testthat/test-matrix_transforms.R @@ -381,14 +381,14 @@ test_that("normalize_log works", { m2 <- as(m, "IterableMatrix") # Test that default params yield the same as log1p on dgCMatrix res_1 <- as(normalize_log(m2), "dgCMatrix") - expect_equal(res_1, log1p(m*1e4)) + expect_equal(res_1, log1p(m*1e4), tolerance = 1e-6) # Test that changing scale factor works res_2 <- as(normalize_log(m2, scale_factor = 1e5), "dgCMatrix") - expect_identical(res_2, log1p(m*1e5)) + expect_equal(res_2, log1p(m*1e5), tolerance = 1e-6) # Test that removing the add_one works # log of 0 is -inf, but we don't do that on the c side, and just have really large negative numbers. res_3 <- as(normalize_log(m2, add_one = FALSE), "dgCMatrix") - res_3@x[res_3@x < -700] <- -Inf - expect_identical(as(res_3, "dgeMatrix"), log(m*1e4)) + res_3@x[res_3@x < -60] <- -Inf + expect_equal(as(res_3, "dgeMatrix"), log(m*1e4), tolerance = 1e-6) }) \ No newline at end of file