X-Git-Url: https://git.auder.net/?p=epclust.git;a=blobdiff_plain;f=epclust%2Ftests%2Ftestthat%2Ftest.filter.R;h=9d1916dbc1d98a58149c4c46ef84c173a06e09bb;hp=d94a5ac8052f1e9261bead01498c9e4a51fd4ee0;hb=0486fbadb122cb4d78c5d9f248c29800a59eb24e;hpb=37c82bbafbffc19e8b47a521952bac58f189e9ea diff --git a/epclust/tests/testthat/test.filter.R b/epclust/tests/testthat/test.filter.R index d94a5ac..9d1916d 100644 --- a/epclust/tests/testthat/test.filter.R +++ b/epclust/tests/testthat/test.filter.R @@ -1,8 +1,18 @@ -TODO: test computeMedoids + filter -# #R-equivalent, requiring a matrix (thus potentially breaking "fit-in-memory" hope) -# mat_meds = medoids[,] -# mi = rep(NA,nb_series) -# for (i in 1:nb_series) -# mi[i] <- which.min( rowSums( sweep(mat_meds, 2, ref_series[i,], '-')^2 ) ) -# rm(mat_meds); gc() +context("epclustFilter") +#TODO: find a better name +test_that("[time-]serie filtering behave as expected", +{ + # Currently just a mean of 3 values + M = matrix(runif(1000,min=-7,max=7), ncol=10) + ref_fM = stats::filter(M, c(1/3,1/3,1/3), circular=FALSE) + fM = epclust:::.epclustFilter(M) + + #Expect an agreement on all inner values + expect_equal(dim(fM), c(100,10)) + expect_equal(fM[2:99,], ref_fM[,2:99]) + + #For border values, just apply a "by-hand" mean + expect_equal(fM[1,], colMeans(rbind(M[1,],M[2,],M[100,]))) + expect_equal(fM[100,], colMeans(rbind(M[100,],M[99,],M[1,]))) +}