X-Git-Url: https://git.auder.net/?p=epclust.git;a=blobdiff_plain;f=epclust%2Ftests%2Ftestthat%2Ftest-computeSynchrones.R;h=60d885e7658ed70c07e65a27038d534994d3b565;hp=db139edefa31db83bc67c02f00110df4f8209ec9;hb=282342bafdc9ff65c5df98c6e2304d63b33b9fb2;hpb=3c5a4b0880db63367a474a568e1322b3999932fe diff --git a/epclust/tests/testthat/test-computeSynchrones.R b/epclust/tests/testthat/test-computeSynchrones.R index db139ed..60d885e 100644 --- a/epclust/tests/testthat/test-computeSynchrones.R +++ b/epclust/tests/testthat/test-computeSynchrones.R @@ -4,28 +4,27 @@ test_that("computeSynchrones behave as expected", { # Generate 300 sinusoïdal series of 3 kinds: all series of indices == 0 mod 3 are the same # (plus noise), all series of indices == 1 mod 3 are the same (plus noise) ... - n = 300 - x = seq(0,9.5,0.1) - L = length(x) #96 1/4h - K = 3 - s1 = cos(x) - s2 = sin(x) - s3 = c( s1[1:(L%/%2)] , s2[(L%/%2+1):L] ) + n <- 300 + x <- seq(0,9.5,0.1) + L <- length(x) #96 1/4h + K <- 3 + s1 <- cos(x) + s2 <- sin(x) + s3 <- c( s1[1:(L%/%2)] , s2[(L%/%2+1):L] ) #sum((s1-s2)^2) == 96 #sum((s1-s3)^2) == 58 #sum((s2-s3)^2) == 38 - s = list(s1, s2, s3) - series = matrix(nrow=L, ncol=n) + s <- list(s1, s2, s3) + series <- matrix(nrow=L, ncol=n) for (i in seq_len(n)) - series[,i] = s[[I(i,K)]] + rnorm(L,sd=0.01) + series[,i] <- s[[I(i,K)]] + rnorm(L,sd=0.01) - getRefSeries = function(indices) { - indices = indices[indices <= n] + getSeries <- function(indices) { + indices <- indices[indices <= n] if (length(indices)>0) as.matrix(series[,indices]) else NULL } - synchrones = computeSynchrones(bigmemory::as.big.matrix(cbind(s1,s2,s3)), getRefSeries, - n, 100, verbose=TRUE, parll=FALSE) + synchrones <- computeSynchrones(cbind(s1,s2,s3),getSeries,n,100,verbose=TRUE,parll=FALSE) expect_equal(dim(synchrones), c(L,K)) for (i in 1:K)