save state; test clustering not OK, all others OK
[epclust.git] / epclust / tests / testthat / test.clustering.R
index a5dc3bd..77faeb9 100644 (file)
@@ -62,7 +62,7 @@ test_that("clusteringTask1 behave as expected",
        L = length(x) #96 1/4h
        K1 = 60
        s = lapply( seq_len(K1), function(i) x^(1+i/30)*cos(x+i) )
-       series = matrix(nrow=n, ncol=L)
+       series = matrix(nrow=L, ncol=n)
        for (i in seq_len(n))
                series[,i] = s[[I(i,K1)]] + rnorm(L,sd=0.01)
        getSeries = function(indices) {
@@ -72,7 +72,10 @@ test_that("clusteringTask1 behave as expected",
        wf = "haar"
        ctype = "absolute"
        getContribs = function(indices) curvesToContribs(series[,indices],wf,ctype)
-       indices1 = clusteringTask1(1:n, getContribs, K1, 75, verbose=TRUE, parll=FALSE)
+       require("cluster", quietly=TRUE)
+       browser()
+       algoClust1 = function(contribs,K) cluster::pam(contribs,K,diss=FALSE)$id.med
+       indices1 = clusteringTask1(1:n, getContribs, K1, algoClust1, 75, verbose=TRUE, parll=FALSE)
        medoids_K1 = getSeries(indices1)
 
        expect_equal(dim(medoids_K1), c(L,K1))
@@ -92,7 +95,7 @@ test_that("clusteringTask2 behave as expected",
        K2 = 3
        #for (i in 1:60) {plot(x^(1+i/30)*cos(x+i),type="l",col=i,ylim=c(-50,50)); par(new=TRUE)}
        s = lapply( seq_len(K1), function(i) x^(1+i/30)*cos(x+i) )
-       series = matrix(nrow=n, ncol=L)
+       series = matrix(nrow=L, ncol=n)
        for (i in seq_len(n))
                series[i,] = s[[I(i,K1)]] + rnorm(L,sd=0.01)
        getRefSeries = function(indices) {