summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrej Shadura <andrewsh@debian.org>2019-03-09 22:30:38 +0000
committerAndrej Shadura <andrewsh@debian.org>2019-03-09 22:30:38 +0000
commit14a486343aef55f97f54082d6b542dedebf6f3ba (patch)
tree000fcc4968578771ad265079eef7617d66de2cda /test
parent8300861dc4c62c5567a4e654976072f854217544 (diff)
Import Upstream version 0.6.0
Diffstat (limited to 'test')
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/AbstractSimpleAlgorithmTest.java6
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/TestKNNJoin.java18
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDBSCANResults.java16
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDeLiCluResults.java2
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestEMResults.java8
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestCOPACResults.java8
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestERiCResults.java8
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansResults.java6
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestP3C.java84
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestPreDeConResults.java2
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestABOD.java10
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestFastABOD.java60
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestLBABOD.java62
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestOnlineLOF.java2
-rw-r--r--test/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/TestSOD.java2
-rw-r--r--test/de/lmu/ifi/dbs/elki/database/TestRelationSorting.java2
-rw-r--r--test/de/lmu/ifi/dbs/elki/datasource/parser/TestTermFrequencyParser.java8
-rw-r--r--test/de/lmu/ifi/dbs/elki/datasource/parser/TestTokenizer.java133
-rw-r--r--test/de/lmu/ifi/dbs/elki/evaluation/paircounting/TestClusterContingencyTable.java2
-rw-r--r--test/de/lmu/ifi/dbs/elki/index/TestIndexStructures.java26
-rw-r--r--test/de/lmu/ifi/dbs/elki/index/preprocessed/TestMaterializedKNNAndRKNNPreprocessor.java10
-rw-r--r--test/de/lmu/ifi/dbs/elki/math/TestKernelDensityFitting.java2
-rw-r--r--test/de/lmu/ifi/dbs/elki/math/TestWeightFunctions.java10
-rw-r--r--test/de/lmu/ifi/dbs/elki/math/statistics/distribution/AbstractDistributionTest.java23
-rw-r--r--test/de/lmu/ifi/dbs/elki/utilities/TestFormatUtil.java84
25 files changed, 504 insertions, 90 deletions
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/AbstractSimpleAlgorithmTest.java b/test/de/lmu/ifi/dbs/elki/algorithm/AbstractSimpleAlgorithmTest.java
index 8b0507f0..3e260e8e 100644
--- a/test/de/lmu/ifi/dbs/elki/algorithm/AbstractSimpleAlgorithmTest.java
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/AbstractSimpleAlgorithmTest.java
@@ -97,7 +97,7 @@ public abstract class AbstractSimpleAlgorithmTest {
*/
protected <T> Database makeSimpleDatabase(String filename, int expectedSize, ListParameterization params, Class<?>[] filters) {
org.junit.Assert.assertTrue("Test data set not found: " + filename, (new File(filename)).exists());
- params.addParameter(FileBasedDatabaseConnection.INPUT_ID, filename);
+ params.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, filename);
List<Class<?>> filterlist = new ArrayList<>();
filterlist.add(FixedDBIDsFilter.class);
@@ -106,8 +106,8 @@ public abstract class AbstractSimpleAlgorithmTest {
filterlist.add(filter);
}
}
- params.addParameter(FileBasedDatabaseConnection.FILTERS_ID, filterlist);
- params.addParameter(FixedDBIDsFilter.IDSTART_ID, 1);
+ params.addParameter(FileBasedDatabaseConnection.Parameterizer.FILTERS_ID, filterlist);
+ params.addParameter(FixedDBIDsFilter.Parameterizer.IDSTART_ID, 1);
Database db = ClassGenericsUtil.parameterizeOrAbort(StaticArrayDatabase.class, params);
testParameterizationOk(params);
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/TestKNNJoin.java b/test/de/lmu/ifi/dbs/elki/algorithm/TestKNNJoin.java
index 3d8ef366..19509350 100644
--- a/test/de/lmu/ifi/dbs/elki/algorithm/TestKNNJoin.java
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/TestKNNJoin.java
@@ -80,10 +80,10 @@ public class TestKNNJoin implements JUnit4Test {
@Test
public void testLinearScan() {
ListParameterization inputparams = new ListParameterization();
- inputparams.addParameter(FileBasedDatabaseConnection.INPUT_ID, dataset);
+ inputparams.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, dataset);
List<Class<?>> filters = Arrays.asList(new Class<?>[] { FixedDBIDsFilter.class });
- inputparams.addParameter(FileBasedDatabaseConnection.FILTERS_ID, filters);
- inputparams.addParameter(FixedDBIDsFilter.IDSTART_ID, 1);
+ inputparams.addParameter(FileBasedDatabaseConnection.Parameterizer.FILTERS_ID, filters);
+ inputparams.addParameter(FixedDBIDsFilter.Parameterizer.IDSTART_ID, 1);
// get database
Database db = ClassGenericsUtil.parameterizeOrAbort(StaticArrayDatabase.class, inputparams);
@@ -130,7 +130,7 @@ public class TestKNNJoin implements JUnit4Test {
@Test
public void testKNNJoinRtreeMini() {
ListParameterization spatparams = new ListParameterization();
- spatparams.addParameter(StaticArrayDatabase.INDEX_ID, RStarTreeFactory.class);
+ spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, RStarTreeFactory.class);
spatparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 200);
doKNNJoin(spatparams);
@@ -144,7 +144,7 @@ public class TestKNNJoin implements JUnit4Test {
@Test
public void testKNNJoinRtreeMaxi() {
ListParameterization spatparams = new ListParameterization();
- spatparams.addParameter(StaticArrayDatabase.INDEX_ID, RStarTreeFactory.class);
+ spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, RStarTreeFactory.class);
spatparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 2000);
doKNNJoin(spatparams);
@@ -158,7 +158,7 @@ public class TestKNNJoin implements JUnit4Test {
@Test
public void testKNNJoinDeLiCluTreeMini() {
ListParameterization spatparams = new ListParameterization();
- spatparams.addParameter(StaticArrayDatabase.INDEX_ID, DeLiCluTreeFactory.class);
+ spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, DeLiCluTreeFactory.class);
spatparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 200);
doKNNJoin(spatparams);
@@ -171,10 +171,10 @@ public class TestKNNJoin implements JUnit4Test {
* @throws ParameterException
*/
void doKNNJoin(ListParameterization inputparams) {
- inputparams.addParameter(FileBasedDatabaseConnection.INPUT_ID, dataset);
+ inputparams.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, dataset);
List<Class<?>> filters = Arrays.asList(new Class<?>[] { FixedDBIDsFilter.class });
- inputparams.addParameter(FileBasedDatabaseConnection.FILTERS_ID, filters);
- inputparams.addParameter(FixedDBIDsFilter.IDSTART_ID, 1);
+ inputparams.addParameter(FileBasedDatabaseConnection.Parameterizer.FILTERS_ID, filters);
+ inputparams.addParameter(FixedDBIDsFilter.Parameterizer.IDSTART_ID, 1);
// get database
Database db = ClassGenericsUtil.parameterizeOrAbort(StaticArrayDatabase.class, inputparams);
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDBSCANResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDBSCANResults.java
index 714f345c..34dd2e3d 100644
--- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDBSCANResults.java
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDBSCANResults.java
@@ -60,8 +60,8 @@ public class TestDBSCANResults extends AbstractSimpleAlgorithmTest implements JU
// setup algorithm
ListParameterization params = new ListParameterization();
- params.addParameter(DBSCAN.EPSILON_ID, 0.04);
- params.addParameter(DBSCAN.MINPTS_ID, 20);
+ params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 0.04);
+ params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 20);
DBSCAN<DoubleVector, DoubleDistance> dbscan = ClassGenericsUtil.parameterizeOrAbort(DBSCAN.class, params);
testParameterizationOk(params);
@@ -84,8 +84,8 @@ public class TestDBSCANResults extends AbstractSimpleAlgorithmTest implements JU
// Setup algorithm
ListParameterization params = new ListParameterization();
- params.addParameter(DBSCAN.EPSILON_ID, 11.5);
- params.addParameter(DBSCAN.MINPTS_ID, 120);
+ params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 11.5);
+ params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 120);
DBSCAN<DoubleVector, DoubleDistance> dbscan = ClassGenericsUtil.parameterizeOrAbort(DBSCAN.class, params);
testParameterizationOk(params);
@@ -107,8 +107,8 @@ public class TestDBSCANResults extends AbstractSimpleAlgorithmTest implements JU
// setup algorithm
ListParameterization params = new ListParameterization();
- params.addParameter(DBSCAN.EPSILON_ID, 0.04);
- params.addParameter(DBSCAN.MINPTS_ID, 20);
+ params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 0.04);
+ params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 20);
GeneralizedDBSCAN dbscan = ClassGenericsUtil.parameterizeOrAbort(GeneralizedDBSCAN.class, params);
testParameterizationOk(params);
@@ -131,8 +131,8 @@ public class TestDBSCANResults extends AbstractSimpleAlgorithmTest implements JU
// Setup algorithm
ListParameterization params = new ListParameterization();
- params.addParameter(DBSCAN.EPSILON_ID, 11.5);
- params.addParameter(DBSCAN.MINPTS_ID, 120);
+ params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 11.5);
+ params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 120);
GeneralizedDBSCAN dbscan = ClassGenericsUtil.parameterizeOrAbort(GeneralizedDBSCAN.class, params);
testParameterizationOk(params);
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDeLiCluResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDeLiCluResults.java
index 1323c5fa..b70c0f67 100644
--- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDeLiCluResults.java
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestDeLiCluResults.java
@@ -62,7 +62,7 @@ public class TestDeLiCluResults extends AbstractSimpleAlgorithmTest implements J
public void testDeLiCluResults() {
ListParameterization indexparams = new ListParameterization();
// We need a special index for this algorithm:
- indexparams.addParameter(StaticArrayDatabase.INDEX_ID, DeLiCluTreeFactory.class);
+ indexparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, DeLiCluTreeFactory.class);
indexparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 1000);
Database db = makeSimpleDatabase(UNITTEST + "hierarchical-2d.ascii", 710, indexparams, null);
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestEMResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestEMResults.java
index 421141a3..065307be 100644
--- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestEMResults.java
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/TestEMResults.java
@@ -57,14 +57,14 @@ public class TestEMResults extends AbstractSimpleAlgorithmTest implements JUnit4
// Setup algorithm
ListParameterization params = new ListParameterization();
- params.addParameter(KMeans.SEED_ID, 1);
- params.addParameter(EM.K_ID, 5);
+ params.addParameter(KMeans.SEED_ID, 0);
+ params.addParameter(EM.Parameterizer.K_ID, 6);
EM<DoubleVector> em = ClassGenericsUtil.parameterizeOrAbort(EM.class, params);
testParameterizationOk(params);
// run EM on database
Clustering<EMModel<DoubleVector>> result = em.run(db);
- testFMeasure(db, result, 0.961587);
- testClusterSizes(result, new int[] { 5, 91, 98, 200, 316 });
+ testFMeasure(db, result, 0.7551098);
+ testClusterSizes(result, new int[] { 50, 99, 102, 120, 141, 198 });
}
} \ No newline at end of file
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestCOPACResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestCOPACResults.java
index 8af036bf..94c59557 100644
--- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestCOPACResults.java
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestCOPACResults.java
@@ -66,8 +66,8 @@ public class TestCOPACResults extends AbstractSimpleAlgorithmTest implements JUn
// these parameters are not picked too smartly - room for improvement.
ListParameterization params = new ListParameterization();
params.addParameter(COPAC.PARTITION_ALGORITHM_ID, DBSCAN.class);
- params.addParameter(DBSCAN.EPSILON_ID, 0.02);
- params.addParameter(DBSCAN.MINPTS_ID, 50);
+ params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 0.02);
+ params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 50);
params.addParameter(COPAC.PREPROCESSOR_ID, KNNQueryFilteredPCAIndex.Factory.class);
params.addParameter(KNNQueryFilteredPCAIndex.Factory.K_ID, 15);
@@ -94,8 +94,8 @@ public class TestCOPACResults extends AbstractSimpleAlgorithmTest implements JUn
// Setup algorithm
ListParameterization params = new ListParameterization();
params.addParameter(COPAC.PARTITION_ALGORITHM_ID, DBSCAN.class);
- params.addParameter(DBSCAN.EPSILON_ID, 0.5);
- params.addParameter(DBSCAN.MINPTS_ID, 20);
+ params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 0.5);
+ params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 20);
params.addParameter(COPAC.PREPROCESSOR_ID, KNNQueryFilteredPCAIndex.Factory.class);
params.addParameter(KNNQueryFilteredPCAIndex.Factory.K_ID, 45);
// PCA
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestERiCResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestERiCResults.java
index 92a61e5e..76e8cca2 100644
--- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestERiCResults.java
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/TestERiCResults.java
@@ -66,8 +66,8 @@ public class TestERiCResults extends AbstractSimpleAlgorithmTest implements JUni
// ERiC
ListParameterization params = new ListParameterization();
params.addParameter(COPAC.PARTITION_ALGORITHM_ID, DBSCAN.class);
- params.addParameter(DBSCAN.MINPTS_ID, 30);
- params.addParameter(DBSCAN.EPSILON_ID, 0);
+ params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 30);
+ params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 0);
// ERiC Distance function in DBSCAN:
params.addParameter(COPAC.PARTITION_DISTANCE_ID, ERiCDistanceFunction.class);
params.addParameter(ERiCDistanceFunction.DELTA_ID, 0.20);
@@ -104,8 +104,8 @@ public class TestERiCResults extends AbstractSimpleAlgorithmTest implements JUni
ListParameterization params = new ListParameterization();
// ERiC
params.addParameter(COPAC.PARTITION_ALGORITHM_ID, DBSCAN.class);
- params.addParameter(DBSCAN.MINPTS_ID, 15);
- params.addParameter(DBSCAN.EPSILON_ID, 0);
+ params.addParameter(DBSCAN.Parameterizer.MINPTS_ID, 15);
+ params.addParameter(DBSCAN.Parameterizer.EPSILON_ID, 0);
// ERiC Distance function in DBSCAN:
params.addParameter(COPAC.PARTITION_DISTANCE_ID, ERiCDistanceFunction.class);
params.addParameter(ERiCDistanceFunction.DELTA_ID, 1.0);
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansResults.java
index 3419352a..3601b977 100644
--- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansResults.java
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/TestKMeansResults.java
@@ -61,7 +61,7 @@ public class TestKMeansResults extends AbstractSimpleAlgorithmTest implements JU
// Setup algorithm
ListParameterization params = new ListParameterization();
params.addParameter(KMeans.K_ID, 5);
- params.addParameter(KMeans.INIT_ID, FirstKInitialMeans.class);
+ params.addParameter(KMeans.SEED_ID, 2);
AbstractKMeans<DoubleVector, DoubleDistance, ?> kmeans = ClassGenericsUtil.parameterizeOrAbort(KMeansLloyd.class, params);
testParameterizationOk(params);
@@ -84,7 +84,7 @@ public class TestKMeansResults extends AbstractSimpleAlgorithmTest implements JU
// Setup algorithm
ListParameterization params = new ListParameterization();
params.addParameter(KMeans.K_ID, 5);
- params.addParameter(KMeans.INIT_ID, FirstKInitialMeans.class);
+ params.addParameter(KMeans.SEED_ID, 2);
AbstractKMeans<DoubleVector, DoubleDistance, ?> kmeans = ClassGenericsUtil.parameterizeOrAbort(KMeansMacQueen.class, params);
testParameterizationOk(params);
@@ -107,7 +107,7 @@ public class TestKMeansResults extends AbstractSimpleAlgorithmTest implements JU
// Setup algorithm
ListParameterization params = new ListParameterization();
params.addParameter(KMeans.K_ID, 5);
- params.addParameter(KMeans.INIT_ID, FirstKInitialMeans.class);
+ params.addParameter(KMeans.SEED_ID, 2);
AbstractKMeans<DoubleVector, DoubleDistance, ?> kmedians = ClassGenericsUtil.parameterizeOrAbort(KMediansLloyd.class, params);
testParameterizationOk(params);
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestP3C.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestP3C.java
new file mode 100644
index 00000000..4d02351f
--- /dev/null
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestP3C.java
@@ -0,0 +1,84 @@
+package de.lmu.ifi.dbs.elki.algorithm.clustering.subspace;
+
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2012
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import org.junit.Test;
+
+import de.lmu.ifi.dbs.elki.JUnit4Test;
+import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest;
+import de.lmu.ifi.dbs.elki.data.Clustering;
+import de.lmu.ifi.dbs.elki.data.DoubleVector;
+import de.lmu.ifi.dbs.elki.data.model.SubspaceModel;
+import de.lmu.ifi.dbs.elki.database.Database;
+import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil;
+import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization;
+
+/**
+ * Test P3C on a simple test data set.
+ *
+ * Note: both data sets are really beneficial for P3C, and with reasonably
+ * chosen parameters, it works perfectly.
+ *
+ * @author Erich Schubert
+ */
+public class TestP3C extends AbstractSimpleAlgorithmTest implements JUnit4Test {
+ /**
+ * Run P3C with fixed parameters and compare the result to a golden standard.
+ */
+ @Test
+ public void testP3CSimple() {
+ Database db = makeSimpleDatabase(UNITTEST + "subspace-simple.csv", 600);
+
+ ListParameterization params = new ListParameterization();
+
+ // setup algorithm
+ P3C<DoubleVector> p3c = ClassGenericsUtil.parameterizeOrAbort(P3C.class, params);
+ testParameterizationOk(params);
+
+ // run P3C on database
+ Clustering<SubspaceModel<DoubleVector>> result = p3c.run(db);
+
+ testFMeasure(db, result, 1.0);
+ testClusterSizes(result, new int[] { 200, 400 });
+ }
+
+ /**
+ * Run P3C with fixed parameters and compare the result to a golden standard.
+ */
+ @Test
+ public void testP3COverlapping() {
+ Database db = makeSimpleDatabase(UNITTEST + "subspace-overlapping-3-4d.ascii", 850);
+
+ // Setup algorithm
+ ListParameterization params = new ListParameterization();
+ params.addParameter(P3C.Parameterizer.ALPHA_THRESHOLD_ID, 0.01);
+ P3C<DoubleVector> p3c = ClassGenericsUtil.parameterizeOrAbort(P3C.class, params);
+ testParameterizationOk(params);
+
+ // run P3C on database
+ Clustering<SubspaceModel<DoubleVector>> result = p3c.run(db);
+ testFMeasure(db, result, 1.0);
+ testClusterSizes(result, new int[] { 150, 300, 400 });
+ }
+} \ No newline at end of file
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestPreDeConResults.java b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestPreDeConResults.java
index a07c71a1..d00a703f 100644
--- a/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestPreDeConResults.java
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/TestPreDeConResults.java
@@ -58,7 +58,7 @@ public class TestPreDeConResults extends AbstractSimpleAlgorithmTest implements
public void testPreDeConResults() {
// Additional input parameters
ListParameterization inp = new ListParameterization();
- inp.addParameter(ClassLabelFilter.CLASS_LABEL_INDEX_ID, 1);
+ inp.addParameter(ClassLabelFilter.Parameterizer.CLASS_LABEL_INDEX_ID, 1);
Class<?>[] filters = new Class<?>[] { ClassLabelFilter.class };
Database db = makeSimpleDatabase(UNITTEST + "axis-parallel-subspace-clusters-6d.csv.gz", 2500, inp, filters);
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestABOD.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestABOD.java
index 3490ce9a..e213b54e 100644
--- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestABOD.java
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestABOD.java
@@ -25,7 +25,6 @@ package de.lmu.ifi.dbs.elki.algorithm.outlier;
import org.junit.Test;
-import de.lmu.ifi.dbs.elki.JUnit4Test;
import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest;
import de.lmu.ifi.dbs.elki.data.DoubleVector;
import de.lmu.ifi.dbs.elki.database.Database;
@@ -36,16 +35,17 @@ import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParamet
/**
* Tests the ABOD algorithm.
*
+ * Note: we don't implement JUnit4Test, as this test is slow.
+ *
* @author Lucia Cichella
*/
-public class TestABOD extends AbstractSimpleAlgorithmTest implements JUnit4Test {
+public class TestABOD extends AbstractSimpleAlgorithmTest {
@Test
public void testABOD() {
Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960);
// Parameterization
ListParameterization params = new ListParameterization();
- params.addParameter(ABOD.K_ID, 5);
// setup Algorithm
ABOD<DoubleVector> abod = ClassGenericsUtil.parameterizeOrAbort(ABOD.class, params);
@@ -54,7 +54,7 @@ public class TestABOD extends AbstractSimpleAlgorithmTest implements JUnit4Test
// run ABOD on database
OutlierResult result = abod.run(db);
- testSingleScore(result, 945, 3.7108897864090475E-4);
- testAUC(db, "Noise", result, 0.9638148148148148);
+ testAUC(db, "Noise", result, 0.94887037037037);
+ testSingleScore(result, 945, 1.88108120738508E-4);
}
} \ No newline at end of file
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestFastABOD.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestFastABOD.java
new file mode 100644
index 00000000..11977af6
--- /dev/null
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestFastABOD.java
@@ -0,0 +1,60 @@
+package de.lmu.ifi.dbs.elki.algorithm.outlier;
+
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2012
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import org.junit.Test;
+
+import de.lmu.ifi.dbs.elki.JUnit4Test;
+import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest;
+import de.lmu.ifi.dbs.elki.data.DoubleVector;
+import de.lmu.ifi.dbs.elki.database.Database;
+import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult;
+import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil;
+import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization;
+
+/**
+ * Tests the ABOD algorithm.
+ *
+ * @author Lucia Cichella
+ */
+public class TestFastABOD extends AbstractSimpleAlgorithmTest implements JUnit4Test {
+ @Test
+ public void testFastABOD() {
+ Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960);
+
+ // Parameterization
+ ListParameterization params = new ListParameterization();
+ params.addParameter(FastABOD.Parameterizer.K_ID, 5);
+
+ // setup Algorithm
+ FastABOD<DoubleVector> abod = ClassGenericsUtil.parameterizeOrAbort(FastABOD.class, params);
+ testParameterizationOk(params);
+
+ // run ABOD on database
+ OutlierResult result = abod.run(db);
+
+ testAUC(db, "Noise", result, 0.963259259259);
+ testSingleScore(result, 945, 0.68723169783);
+ }
+} \ No newline at end of file
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestLBABOD.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestLBABOD.java
new file mode 100644
index 00000000..5a1f56f2
--- /dev/null
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/TestLBABOD.java
@@ -0,0 +1,62 @@
+package de.lmu.ifi.dbs.elki.algorithm.outlier;
+
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2012
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import org.junit.Test;
+
+import de.lmu.ifi.dbs.elki.algorithm.AbstractSimpleAlgorithmTest;
+import de.lmu.ifi.dbs.elki.data.DoubleVector;
+import de.lmu.ifi.dbs.elki.database.Database;
+import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult;
+import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil;
+import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization;
+
+/**
+ * Tests the LB-ABOD algorithm.
+ *
+ * Note: we don't implement JUnit4Test, as this test is slow.
+ *
+ * @author Lucia Cichella
+ */
+public class TestLBABOD extends AbstractSimpleAlgorithmTest {
+ @Test
+ public void testLBABOD() {
+ Database db = makeSimpleDatabase(UNITTEST + "outlier-3d-3clusters.ascii", 960);
+
+ // Parameterization
+ ListParameterization params = new ListParameterization();
+ params.addParameter(FastABOD.Parameterizer.K_ID, 150);
+ params.addParameter(LBABOD.Parameterizer.L_ID, 10);
+
+ // setup Algorithm
+ LBABOD<DoubleVector> abod = ClassGenericsUtil.parameterizeOrAbort(LBABOD.class, params);
+ testParameterizationOk(params);
+
+ // run ABOD on database
+ OutlierResult result = abod.run(db);
+
+ testAUC(db, "Noise", result, 0.928999999999);
+ testSingleScore(result, 945, 1.88108120738508E-4);
+ }
+} \ No newline at end of file
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestOnlineLOF.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestOnlineLOF.java
index cd60a58f..889cddce 100644
--- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestOnlineLOF.java
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/TestOnlineLOF.java
@@ -152,7 +152,7 @@ public class TestOnlineLOF implements JUnit4Test {
*/
private static UpdatableDatabase getDatabase() {
ListParameterization params = new ListParameterization();
- params.addParameter(FileBasedDatabaseConnection.INPUT_ID, dataset);
+ params.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, dataset);
UpdatableDatabase db = ClassGenericsUtil.parameterizeOrAbort(HashmapDatabase.class, params);
params.failOnErrors();
diff --git a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/TestSOD.java b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/TestSOD.java
index c43f2f35..f8f47886 100644
--- a/test/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/TestSOD.java
+++ b/test/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/TestSOD.java
@@ -47,7 +47,7 @@ public class TestSOD extends AbstractSimpleAlgorithmTest implements JUnit4Test {
// Parameterization
ListParameterization params = new ListParameterization();
- params.addParameter(SOD.KNN_ID, 25);
+ params.addParameter(SOD.Parameterizer.KNN_ID, 25);
params.addParameter(SharedNearestNeighborPreprocessor.Factory.NUMBER_OF_NEIGHBORS_ID, 19);
// setup Algorithm
diff --git a/test/de/lmu/ifi/dbs/elki/database/TestRelationSorting.java b/test/de/lmu/ifi/dbs/elki/database/TestRelationSorting.java
index 01ec174c..2b77f2f5 100644
--- a/test/de/lmu/ifi/dbs/elki/database/TestRelationSorting.java
+++ b/test/de/lmu/ifi/dbs/elki/database/TestRelationSorting.java
@@ -56,7 +56,7 @@ public class TestRelationSorting implements JUnit4Test {
@Test
public void testSorting() {
ListParameterization params = new ListParameterization();
- params.addParameter(FileBasedDatabaseConnection.INPUT_ID, filename);
+ params.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, filename);
Database db = ClassGenericsUtil.parameterizeOrAbort(StaticArrayDatabase.class, params);
if (params.hasUnusedParameters()) {
fail("Unused parameters: " + params.getRemainingParameters());
diff --git a/test/de/lmu/ifi/dbs/elki/datasource/parser/TestTermFrequencyParser.java b/test/de/lmu/ifi/dbs/elki/datasource/parser/TestTermFrequencyParser.java
index bf5e2791..2bf288f7 100644
--- a/test/de/lmu/ifi/dbs/elki/datasource/parser/TestTermFrequencyParser.java
+++ b/test/de/lmu/ifi/dbs/elki/datasource/parser/TestTermFrequencyParser.java
@@ -62,14 +62,14 @@ public class TestTermFrequencyParser implements JUnit4Test {
@Test
public void testDBLPData() {
ListParameterization config = new ListParameterization();
- config.addParameter(AbstractDatabaseConnection.PARSER_ID, TermFrequencyParser.class);
- config.addParameter(FileBasedDatabaseConnection.INPUT_ID, DBLP_DATA);
+ config.addParameter(AbstractDatabaseConnection.Parameterizer.PARSER_ID, TermFrequencyParser.class);
+ config.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, DBLP_DATA);
ArrayList<Object> filters = new ArrayList<>();
filters.add(TFIDFNormalization.class);
- // Note: this filter is needed for the non-sparse euclidean distance below.
+ // Note: this filter is needed for the non-sparse Euclidean distance below.
filters.add(SparseVectorFieldFilter.class);
- config.addParameter(AbstractDatabaseConnection.FILTERS_ID, filters);
+ config.addParameter(AbstractDatabaseConnection.Parameterizer.FILTERS_ID, filters);
Database db = ClassGenericsUtil.parameterizeOrAbort(StaticArrayDatabase.class, config);
diff --git a/test/de/lmu/ifi/dbs/elki/datasource/parser/TestTokenizer.java b/test/de/lmu/ifi/dbs/elki/datasource/parser/TestTokenizer.java
new file mode 100644
index 00000000..34ccdc04
--- /dev/null
+++ b/test/de/lmu/ifi/dbs/elki/datasource/parser/TestTokenizer.java
@@ -0,0 +1,133 @@
+package de.lmu.ifi.dbs.elki.datasource.parser;
+
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2013
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.regex.Pattern;
+
+import org.junit.Test;
+
+import de.lmu.ifi.dbs.elki.JUnit4Test;
+
+/**
+ * Simple unit test for testing the new tokenizer
+ *
+ * TODO: add more test cases, refactor into input, expected-output pattern.
+ *
+ * @author Erich Schubert
+ */
+public class TestTokenizer implements JUnit4Test {
+ Tokenizer t = new Tokenizer(Pattern.compile("\\s"), "\"'");
+
+ @Test
+ public void testSimple() {
+ final String input = "1 -234 3.1415 - banana";
+ final Object[] expect = { 1L, -234L, 3.1415, "-", "banana" };
+ t.initialize(input, 0, input.length());
+ tokenizerTest(expect);
+ }
+
+ @Test
+ public void testQuotes() {
+ final String input = "'this is' \"a test\" '123' '123 456' \"bana' na\"";
+ final Object[] expect = { "this is", "a test", 123L, "123 456", "bana' na" };
+ t.initialize(input, 0, input.length());
+ tokenizerTest(expect);
+ }
+
+ @Test
+ public void testSpecials() {
+ final String input = "nan inf -∞ NaN infinity NA";
+ final Object[] expect = { Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NaN, Double.POSITIVE_INFINITY, Double.NaN };
+ t.initialize(input, 0, input.length());
+ tokenizerTest(expect);
+ }
+
+ @Test
+ public void testEmpty() {
+ final String input = "";
+ final Object[] expect = {};
+ t.initialize(input, 0, input.length());
+ tokenizerTest(expect);
+ }
+
+ @Test
+ public void testLineEnd() {
+ final String input = "1 ";
+ final Object[] expect = { 1L };
+ t.initialize(input, 0, input.length());
+ tokenizerTest(expect);
+ }
+
+ @Test
+ public void testPartial() {
+ final String input = "abc1def";
+ final Object[] expect = { 1L };
+ t.initialize(input, 3, 4);
+ tokenizerTest(expect);
+ }
+
+ private void tokenizerTest(Object[] expect) {
+ for(int i = 0; i < expect.length; i++, t.advance()) {
+ assertTrue("Tokenizer stopped early.", t.valid());
+ Object e = expect[i];
+ // Negative tests first:
+ if(e instanceof String || e instanceof Double) {
+ try {
+ long val = t.getLongBase10();
+ fail("The value " + t.getSubstring() + " was expected to be not parseable as long integer, but returned: " + val);
+ }
+ catch(Exception ex) {
+ // pass. this is expected to fail.
+ }
+ }
+ if(e instanceof String) {
+ try {
+ double val = t.getDouble();
+ fail("The value " + t.getSubstring() + " was expected to be not parseable as double, but returned: " + val);
+ }
+ catch(Exception ex) {
+ // pass. this is expected to fail.
+ }
+ }
+ // Positive tests:
+ if(e instanceof Long) {
+ assertEquals("Long parsing failed.", (long) e, t.getLongBase10());
+ }
+ if(e instanceof Double) {
+ // Note: this also works for NaNs, they are treated special.
+ assertEquals("Double parsing failed.", (double) e, t.getDouble(), Double.MIN_VALUE);
+ }
+ if(e instanceof String) {
+ assertEquals("String parsing failed.", (String) e, t.getSubstring());
+ }
+ }
+ if(t.valid()) {
+ assertTrue("Spurous data after expected end: " + t.getSubstring(), !t.valid());
+ }
+ }
+}
diff --git a/test/de/lmu/ifi/dbs/elki/evaluation/paircounting/TestClusterContingencyTable.java b/test/de/lmu/ifi/dbs/elki/evaluation/paircounting/TestClusterContingencyTable.java
index 42188f56..bc83e534 100644
--- a/test/de/lmu/ifi/dbs/elki/evaluation/paircounting/TestClusterContingencyTable.java
+++ b/test/de/lmu/ifi/dbs/elki/evaluation/paircounting/TestClusterContingencyTable.java
@@ -67,7 +67,7 @@ public class TestClusterContingencyTable implements JUnit4Test {
public void testCompareDatabases() {
ListParameterization params = new ListParameterization();
// Input
- params.addParameter(FileBasedDatabaseConnection.INPUT_ID, dataset);
+ params.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, dataset);
// get database
Database db = ClassGenericsUtil.parameterizeOrAbort(StaticArrayDatabase.class, params);
diff --git a/test/de/lmu/ifi/dbs/elki/index/TestIndexStructures.java b/test/de/lmu/ifi/dbs/elki/index/TestIndexStructures.java
index 1623bcfa..b412e409 100644
--- a/test/de/lmu/ifi/dbs/elki/index/TestIndexStructures.java
+++ b/test/de/lmu/ifi/dbs/elki/index/TestIndexStructures.java
@@ -37,9 +37,9 @@ import de.lmu.ifi.dbs.elki.database.ids.distance.DistanceDBIDList;
import de.lmu.ifi.dbs.elki.database.ids.distance.DistanceDBIDListIter;
import de.lmu.ifi.dbs.elki.database.ids.distance.KNNList;
import de.lmu.ifi.dbs.elki.database.query.distance.DistanceQuery;
+import de.lmu.ifi.dbs.elki.database.query.knn.DoubleOptimizedDistanceKNNQuery;
import de.lmu.ifi.dbs.elki.database.query.knn.KNNQuery;
-import de.lmu.ifi.dbs.elki.database.query.knn.LinearScanKNNQuery;
-import de.lmu.ifi.dbs.elki.database.query.range.LinearScanRangeQuery;
+import de.lmu.ifi.dbs.elki.database.query.range.DoubleOptimizedDistanceRangeQuery;
import de.lmu.ifi.dbs.elki.database.query.range.RangeQuery;
import de.lmu.ifi.dbs.elki.database.relation.Relation;
import de.lmu.ifi.dbs.elki.datasource.FileBasedDatabaseConnection;
@@ -98,7 +98,7 @@ public class TestIndexStructures implements JUnit4Test {
@Test
public void testExact() {
ListParameterization params = new ListParameterization();
- testFileBasedDatabaseConnection(params, LinearScanKNNQuery.class, LinearScanRangeQuery.class);
+ testFileBasedDatabaseConnection(params, DoubleOptimizedDistanceKNNQuery.class, DoubleOptimizedDistanceRangeQuery.class);
}
/**
@@ -107,7 +107,7 @@ public class TestIndexStructures implements JUnit4Test {
@Test
public void testMetrical() {
ListParameterization metparams = new ListParameterization();
- metparams.addParameter(StaticArrayDatabase.INDEX_ID, MTreeFactory.class);
+ metparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, MTreeFactory.class);
metparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 300);
testFileBasedDatabaseConnection(metparams, DoubleDistanceMetricalIndexKNNQuery.class, DoubleDistanceMetricalIndexRangeQuery.class);
}
@@ -118,7 +118,7 @@ public class TestIndexStructures implements JUnit4Test {
@Test
public void testRStarTree() {
ListParameterization spatparams = new ListParameterization();
- spatparams.addParameter(StaticArrayDatabase.INDEX_ID, RStarTreeFactory.class);
+ spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, RStarTreeFactory.class);
spatparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 300);
testFileBasedDatabaseConnection(spatparams, DoubleDistanceRStarTreeKNNQuery.class, DoubleDistanceRStarTreeRangeQuery.class);
}
@@ -129,7 +129,7 @@ public class TestIndexStructures implements JUnit4Test {
@Test
public void testVAFile() {
ListParameterization spatparams = new ListParameterization();
- spatparams.addParameter(StaticArrayDatabase.INDEX_ID, VAFile.Factory.class);
+ spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, VAFile.Factory.class);
spatparams.addParameter(VAFile.Factory.PARTITIONS_ID, 4);
testFileBasedDatabaseConnection(spatparams, VAFile.VAFileKNNQuery.class, VAFile.VAFileRangeQuery.class);
}
@@ -140,7 +140,7 @@ public class TestIndexStructures implements JUnit4Test {
@Test
public void testPartialVAFile() {
ListParameterization spatparams = new ListParameterization();
- spatparams.addParameter(StaticArrayDatabase.INDEX_ID, PartialVAFile.Factory.class);
+ spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, PartialVAFile.Factory.class);
spatparams.addParameter(PartialVAFile.Factory.PARTITIONS_ID, 4);
testFileBasedDatabaseConnection(spatparams, PartialVAFile.PartialVAFileKNNQuery.class, PartialVAFile.PartialVAFileRangeQuery.class);
}
@@ -153,7 +153,7 @@ public class TestIndexStructures implements JUnit4Test {
@Test
public void testRStarTreeFast() {
ListParameterization spatparams = new ListParameterization();
- spatparams.addParameter(StaticArrayDatabase.INDEX_ID, RStarTreeFactory.class);
+ spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID, RStarTreeFactory.class);
spatparams.addParameter(AbstractRStarTreeFactory.Parameterizer.INSERTION_STRATEGY_ID, ApproximativeLeastOverlapInsertionStrategy.class);
spatparams.addParameter(ApproximativeLeastOverlapInsertionStrategy.Parameterizer.INSERTION_CANDIDATES_ID, 1);
spatparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 300);
@@ -180,7 +180,7 @@ public class TestIndexStructures implements JUnit4Test {
* @param inputparams
*/
void testFileBasedDatabaseConnection(ListParameterization inputparams, Class<?> expectKNNQuery, Class<?> expectRangeQuery) {
- inputparams.addParameter(FileBasedDatabaseConnection.INPUT_ID, dataset);
+ inputparams.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, dataset);
// get database
Database db = ClassGenericsUtil.parameterizeOrAbort(StaticArrayDatabase.class, inputparams);
@@ -195,13 +195,13 @@ public class TestIndexStructures implements JUnit4Test {
// get the 10 next neighbors
DoubleVector dv = new DoubleVector(querypoint);
KNNQuery<DoubleVector, DoubleDistance> knnq = db.getKNNQuery(dist, k);
- assertTrue("Returned knn query is not of expected class.", expectKNNQuery.isAssignableFrom(knnq.getClass()));
+ assertTrue("Returned knn query is not of expected class: expected " + expectKNNQuery + " got " + knnq.getClass(), expectKNNQuery.isAssignableFrom(knnq.getClass()));
KNNList<DoubleDistance> ids = knnq.getKNNForObject(dv, k);
assertEquals("Result size does not match expectation!", shouldd.length, ids.size());
// verify that the neighbors match.
int i = 0;
- for (DistanceDBIDListIter<DoubleDistance> res = ids.iter(); res.valid(); res.advance(), i++) {
+ for(DistanceDBIDListIter<DoubleDistance> res = ids.iter(); res.valid(); res.advance(), i++) {
// Verify distance
assertEquals("Expected distance doesn't match.", shouldd[i], res.getDistance().doubleValue());
// verify vector
@@ -214,13 +214,13 @@ public class TestIndexStructures implements JUnit4Test {
// Do a range query
DoubleVector dv = new DoubleVector(querypoint);
RangeQuery<DoubleVector, DoubleDistance> rangeq = db.getRangeQuery(dist, eps);
- assertTrue("Returned range query is not of expected class.", expectRangeQuery.isAssignableFrom(rangeq.getClass()));
+ assertTrue("Returned range query is not of expected class: expected " + expectRangeQuery + " got " + rangeq.getClass(), expectRangeQuery.isAssignableFrom(rangeq.getClass()));
DistanceDBIDList<DoubleDistance> ids = rangeq.getRangeForObject(dv, eps);
assertEquals("Result size does not match expectation!", shouldd.length, ids.size());
// verify that the neighbors match.
int i = 0;
- for (DistanceDBIDListIter<DoubleDistance> res = ids.iter(); res.valid(); res.advance(), i++) {
+ for(DistanceDBIDListIter<DoubleDistance> res = ids.iter(); res.valid(); res.advance(), i++) {
// Verify distance
assertEquals("Expected distance doesn't match.", shouldd[i], res.getDistance().doubleValue());
// verify vector
diff --git a/test/de/lmu/ifi/dbs/elki/index/preprocessed/TestMaterializedKNNAndRKNNPreprocessor.java b/test/de/lmu/ifi/dbs/elki/index/preprocessed/TestMaterializedKNNAndRKNNPreprocessor.java
index 68202213..10bd8a1e 100644
--- a/test/de/lmu/ifi/dbs/elki/index/preprocessed/TestMaterializedKNNAndRKNNPreprocessor.java
+++ b/test/de/lmu/ifi/dbs/elki/index/preprocessed/TestMaterializedKNNAndRKNNPreprocessor.java
@@ -47,7 +47,7 @@ import de.lmu.ifi.dbs.elki.database.ids.distance.DistanceDBIDListIter;
import de.lmu.ifi.dbs.elki.database.ids.distance.KNNList;
import de.lmu.ifi.dbs.elki.database.query.distance.DistanceQuery;
import de.lmu.ifi.dbs.elki.database.query.knn.KNNQuery;
-import de.lmu.ifi.dbs.elki.database.query.knn.LinearScanKNNQuery;
+import de.lmu.ifi.dbs.elki.database.query.knn.LinearScanDistanceKNNQuery;
import de.lmu.ifi.dbs.elki.database.query.rknn.LinearScanRKNNQuery;
import de.lmu.ifi.dbs.elki.database.query.rknn.RKNNQuery;
import de.lmu.ifi.dbs.elki.database.relation.Relation;
@@ -98,7 +98,7 @@ public class TestMaterializedKNNAndRKNNPreprocessor implements JUnit4Test {
@Test
public void testPreprocessor() throws ParameterException, UnableToComplyException {
ListParameterization params = new ListParameterization();
- params.addParameter(FileBasedDatabaseConnection.INPUT_ID, dataset);
+ params.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, dataset);
// get database
UpdatableDatabase db = ClassGenericsUtil.parameterizeOrAbort(HashmapDatabase.class, params);
@@ -110,7 +110,7 @@ public class TestMaterializedKNNAndRKNNPreprocessor implements JUnit4Test {
assertEquals("Data set size doesn't match parameters.", shoulds, rep.size());
// get linear queries
- LinearScanKNNQuery<DoubleVector, DoubleDistance> lin_knn_query = new LinearScanKNNQuery<>(distanceQuery);
+ LinearScanDistanceKNNQuery<DoubleVector, DoubleDistance> lin_knn_query = new LinearScanDistanceKNNQuery<>(distanceQuery);
LinearScanRKNNQuery<DoubleVector, DoubleDistance> lin_rknn_query = new LinearScanRKNNQuery<>(distanceQuery, lin_knn_query, k);
// get preprocessed queries
@@ -122,8 +122,8 @@ public class TestMaterializedKNNAndRKNNPreprocessor implements JUnit4Test {
RKNNQuery<DoubleVector, DoubleDistance> preproc_rknn_query = preproc.getRKNNQuery(distanceQuery);
// add as index
db.addIndex(preproc);
- assertTrue("Preprocessor knn query class incorrect.", !(preproc_knn_query instanceof LinearScanKNNQuery));
- assertTrue("Preprocessor rknn query class incorrect.", !(preproc_rknn_query instanceof LinearScanKNNQuery));
+ assertTrue("Preprocessor knn query class incorrect.", !(preproc_knn_query instanceof LinearScanDistanceKNNQuery));
+ assertTrue("Preprocessor rknn query class incorrect.", !(preproc_rknn_query instanceof LinearScanDistanceKNNQuery));
// test queries
testKNNQueries(rep, lin_knn_query, preproc_knn_query, k);
diff --git a/test/de/lmu/ifi/dbs/elki/math/TestKernelDensityFitting.java b/test/de/lmu/ifi/dbs/elki/math/TestKernelDensityFitting.java
index 795b7c94..57129241 100644
--- a/test/de/lmu/ifi/dbs/elki/math/TestKernelDensityFitting.java
+++ b/test/de/lmu/ifi/dbs/elki/math/TestKernelDensityFitting.java
@@ -75,7 +75,7 @@ public class TestKernelDensityFitting implements JUnit4Test {
public final void testFitDoubleArray() {
ListParameterization config = new ListParameterization();
// Input
- config.addParameter(FileBasedDatabaseConnection.INPUT_ID, dataset);
+ config.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, dataset);
// This data was generated with a mean of 0.0 and stddev 1.23,
// get database
diff --git a/test/de/lmu/ifi/dbs/elki/math/TestWeightFunctions.java b/test/de/lmu/ifi/dbs/elki/math/TestWeightFunctions.java
index c24bab2e..d2a71615 100644
--- a/test/de/lmu/ifi/dbs/elki/math/TestWeightFunctions.java
+++ b/test/de/lmu/ifi/dbs/elki/math/TestWeightFunctions.java
@@ -53,7 +53,7 @@ public class TestWeightFunctions implements JUnit4Test {
double[] at0 = { 1.0, 1.0, 1.0, 1.0, 0.3989422804014327, 1.0, 1.0 };
double[] at01 = { 1.0, 0.8693490686884612, 0.920344325445942, 0.9772372209558107, 0.3969525474770118, 0.91, 0.7943282347242815 };
double[] at09 = { 1.0, 0.13877499454059491, 0.36812025069351895, 0.15488166189124816, 0.2660852498987548, 0.18999999999999995, 0.12589254117941673 };
- double[] at10 = { 1.0, 0.10000000000000016, 0.317310507862914, 0.10000000000000002, 0.24197072451914337, 0.09999999999999998, 0.10000000000000002 };
+ double[] at10 = { 1.0, 0.10000000000000016, 0.31731050786291404, 0.10000000000000002, 0.24197072451914337, 0.09999999999999998, 0.10000000000000002 };
assert (wf.length == at0.length);
assert (wf.length == at01.length);
@@ -65,10 +65,10 @@ public class TestWeightFunctions implements JUnit4Test {
double val01 = wf[i].getWeight(0.1, 1, 1);
double val09 = wf[i].getWeight(0.9, 1, 1);
double val10 = wf[i].getWeight(1.0, 1, 1);
- assertEquals(wf[i].getClass().getSimpleName() + " at 0.0", at0[i], val0, Double.MIN_VALUE);
- assertEquals(wf[i].getClass().getSimpleName() + " at 0.1", at01[i], val01, Double.MIN_VALUE);
- assertEquals(wf[i].getClass().getSimpleName() + " at 0.9", at09[i], val09, Double.MIN_VALUE);
- assertEquals(wf[i].getClass().getSimpleName() + " at 1.0", at10[i], val10, Double.MIN_VALUE);
+ assertEquals(wf[i].getClass().getSimpleName() + " at 0.0", at0[i], val0, 1e-15);
+ assertEquals(wf[i].getClass().getSimpleName() + " at 0.1", at01[i], val01, 1e-15);
+ assertEquals(wf[i].getClass().getSimpleName() + " at 0.9", at09[i], val09, 1e-15);
+ assertEquals(wf[i].getClass().getSimpleName() + " at 1.0", at10[i], val10, 1e-15);
}
}
diff --git a/test/de/lmu/ifi/dbs/elki/math/statistics/distribution/AbstractDistributionTest.java b/test/de/lmu/ifi/dbs/elki/math/statistics/distribution/AbstractDistributionTest.java
index 3e613e4a..63a19072 100644
--- a/test/de/lmu/ifi/dbs/elki/math/statistics/distribution/AbstractDistributionTest.java
+++ b/test/de/lmu/ifi/dbs/elki/math/statistics/distribution/AbstractDistributionTest.java
@@ -10,7 +10,7 @@ import static org.junit.Assert.assertTrue;
*/
public class AbstractDistributionTest {
public void checkPDF(Distribution d, double[] x, double[] expected, double err) {
- int maxerrlev = Integer.MIN_VALUE;
+ int maxerrlev = -15;
for(int i = 0; i < x.length; i++) {
double val = d.pdf(x[i]);
if(val == expected[i]) {
@@ -25,14 +25,11 @@ public class AbstractDistributionTest {
assertEquals("Error magnitude: 1e" + errlev + " at " + x[i], expected[i], val, err);
}
int given = (int) Math.floor(Math.log10(err * 1.1));
- // if (given > maxerrlev) {
- // System.err.println("PDF Error for "+d+" magnitude is not tight: expected "+maxerrlev+" got "+given);
- // }
- assertTrue("Error magnitude is not tight: expected " + maxerrlev + " got " + given, given <= maxerrlev);
+ assertTrue("Error magnitude is not tight: measured " + maxerrlev + " specified " + given, given <= maxerrlev);
}
public void checkCDF(Distribution d, double[] x, double[] expected, double err) {
- int maxerrlev = Integer.MIN_VALUE;
+ int maxerrlev = -15;
for(int i = 0; i < x.length; i++) {
double val = d.cdf(x[i]);
if(val == expected[i]) {
@@ -47,16 +44,13 @@ public class AbstractDistributionTest {
assertEquals("Error magnitude: 1e" + errlev + " at " + x[i], expected[i], val, err);
}
int given = (int) Math.floor(Math.log10(err * 1.1));
- // if (given > maxerrlev) {
- // System.err.println("CDF Error for "+d+" magnitude is not tight: expected "+maxerrlev+" got "+given);
- // }
- assertTrue("Error magnitude is not tight: expected " + maxerrlev + " got " + given, given <= maxerrlev);
+ assertTrue("Error magnitude is not tight: measured " + maxerrlev + " specified " + given, given <= maxerrlev);
}
public void checkQuantile(Distribution d, double[] x, double[] expected, double err) {
- int maxerrlev = Integer.MIN_VALUE;
+ int maxerrlev = -15;
for(int i = 0; i < x.length; i++) {
- if (Double.isNaN(expected[i])) {
+ if(Double.isNaN(expected[i])) {
continue;
}
double val = d.quantile(x[i]);
@@ -72,9 +66,6 @@ public class AbstractDistributionTest {
assertEquals("Error magnitude: 1e" + errlev + " at " + x[i], expected[i], val, err);
}
int given = (int) Math.floor(Math.log10(err * 1.1));
- // if (given > maxerrlev) {
- // System.err.println("Probit Error for "+d+" magnitude is not tight: expected "+maxerrlev+" got "+given);
- // }
- assertTrue("Error magnitude is not tight: expected " + maxerrlev + " got " + given, given <= maxerrlev);
+ assertTrue("Error magnitude is not tight: measured " + maxerrlev + " specified " + given, given <= maxerrlev);
}
} \ No newline at end of file
diff --git a/test/de/lmu/ifi/dbs/elki/utilities/TestFormatUtil.java b/test/de/lmu/ifi/dbs/elki/utilities/TestFormatUtil.java
new file mode 100644
index 00000000..93a739ba
--- /dev/null
+++ b/test/de/lmu/ifi/dbs/elki/utilities/TestFormatUtil.java
@@ -0,0 +1,84 @@
+package de.lmu.ifi.dbs.elki.utilities;
+
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2012
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import de.lmu.ifi.dbs.elki.JUnit4Test;
+
+public class TestFormatUtil implements JUnit4Test {
+ @Test
+ public void testParseDouble() {
+ assertEquals(0., FormatUtil.parseDouble("0"), 0.);
+ assertEquals(1., FormatUtil.parseDouble("1"), 0.);
+ assertEquals(-1., FormatUtil.parseDouble("-1"), 0.);
+ assertEquals(0., FormatUtil.parseDouble("0.0"), 0.);
+ assertEquals(1., FormatUtil.parseDouble("1.0"), 0.);
+ assertEquals(-1., FormatUtil.parseDouble("-1.0"), 0.);
+ assertEquals(.2, FormatUtil.parseDouble("0.2"), 0.);
+ assertEquals(-.2, FormatUtil.parseDouble("-0.2"), 0.);
+ assertEquals(.2, FormatUtil.parseDouble(".2"), 0.);
+ assertEquals(-.2, FormatUtil.parseDouble("-.2"), 0.);
+ assertEquals(2000., FormatUtil.parseDouble("2.0e3"), 0.);
+ assertEquals(2000., FormatUtil.parseDouble("2.0E3"), 0.);
+ assertEquals(-2000., FormatUtil.parseDouble("-2.0e3"), 0.);
+ assertEquals(-2000., FormatUtil.parseDouble("-2.0E3"), 0.);
+ assertEquals(.002, FormatUtil.parseDouble("2.0e-3"), 0.);
+ assertEquals(.002, FormatUtil.parseDouble("2.0E-3"), 0.);
+ assertEquals(-.002, FormatUtil.parseDouble("-2.0e-3"), 0.);
+ assertEquals(-.002, FormatUtil.parseDouble("-2.0E-3"), 0.);
+
+ // Case where the JDK had a serious bug, in a few variations
+ assertEquals(2.2250738585072012e-308, FormatUtil.parseDouble("2.2250738585072012e-308"), 0.);
+ assertEquals(0.00022250738585072012e-304, FormatUtil.parseDouble("0.00022250738585072012e-304"), 0.);
+ assertEquals(00000000002.2250738585072012e-308, FormatUtil.parseDouble("00000000002.2250738585072012e-308"), 0.);
+ assertEquals(2.2250738585072012e-00308, FormatUtil.parseDouble("2.2250738585072012e-00308"), 0.);
+
+ assertTrue(Double.POSITIVE_INFINITY == FormatUtil.parseDouble("inf"));
+ assertTrue(Double.NEGATIVE_INFINITY == FormatUtil.parseDouble("-inf"));
+ assertTrue(Double.POSITIVE_INFINITY == FormatUtil.parseDouble("∞"));
+ assertTrue(Double.NEGATIVE_INFINITY == FormatUtil.parseDouble("-∞"));
+ assertTrue(Double.isNaN(FormatUtil.parseDouble("nan")));
+
+ assertEquals(1, FormatUtil.parseDouble("+1"), 0.);
+ }
+
+ @Test(expected = NumberFormatException.class)
+ public void textOnlyPlus() {
+ FormatUtil.parseDouble("+");
+ }
+
+ @Test(expected = NumberFormatException.class)
+ public void textExtraCharacer() {
+ FormatUtil.parseDouble("123Banana");
+ }
+
+ @Test(expected = NumberFormatException.class)
+ public void textTooManyDigits() {
+ FormatUtil.parseDouble("123456789012345678901234567890");
+ }
+}