X-Git-Url: https://git.auder.net/?p=epclust.git;a=blobdiff_plain;f=epclust%2Ftests%2Ftestthat%2Ftest.computeMedoidsIndices.R;h=8347fb6fbf501a01d4e631fdc58f62bbec195658;hp=efd6af909d4cfcfa3017723afa427b2ee3c57896;hb=0fe757f750f51e580d2c5a7b7f7df87cc405d12d;hpb=0486fbadb122cb4d78c5d9f248c29800a59eb24e diff --git a/epclust/tests/testthat/test.computeMedoidsIndices.R b/epclust/tests/testthat/test.computeMedoidsIndices.R index efd6af9..8347fb6 100644 --- a/epclust/tests/testthat/test.computeMedoidsIndices.R +++ b/epclust/tests/testthat/test.computeMedoidsIndices.R @@ -8,17 +8,18 @@ test_that("computeMedoidsIndices behave as expected", medoids = cbind( rep(0,L), rep(-5,L), rep(5,L) ) # short series... series = t( rbind( MASS::mvrnorm(n/3, medoids[,1], diag(L)), - MASS::mvrnorm(n/3, medoids[,2], diag(L), - MASS::mvrnorm(n/3, medoids[,3], diag(L))) ) ) + MASS::mvrnorm(n/3, medoids[,2], diag(L)), + MASS::mvrnorm(n/3, medoids[,3], diag(L)) ) ) # With high probability, medoids indices should resemble 1,1,1,...,2,2,2,...,3,3,3,... - mi = epclust:::.computeMedoidsIndices(medoids, series) + require("bigmemory", quietly=TRUE) + mi = epclust:::computeMedoidsIndices(bigmemory::as.big.matrix(medoids)@address, series) mi_ref = rep(1:3, each=n/3) - expect_that( mean(mi != mi_ref) < 0.01 ) + expect_lt( mean(mi != mi_ref), 0.01 ) # Now with a random matrix, compare with (trusted) R version series = matrix(runif(n*L, min=-7, max=7), nrow=L) - mi = epclust:::.computeMedoidsIndices(medoids, series) + mi = epclust:::computeMedoidsIndices(bigmemory::as.big.matrix(medoids)@address, series) mi_ref = R_computeMedoidsIndices(medoids, series) expect_equal(mi, mi_ref) })