[mlpack-git] master: Refactor tests for NeighborSearch API. (03b73c6)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Wed Apr 22 16:32:25 EDT 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/8f85309ae9be40e819b301b39c9a940aa28f3bb2...57d0567dddff01feea73b348f38cc040dc3cf8e3

>---------------------------------------------------------------

commit 03b73c6b07cffc1e0315b9d1e7c13a6634abd2a5
Author: ryan <ryan at ratml.org>
Date:   Wed Apr 22 14:19:59 2015 -0400

    Refactor tests for NeighborSearch API.


>---------------------------------------------------------------

03b73c6b07cffc1e0315b9d1e7c13a6634abd2a5
 src/mlpack/tests/allkfn_test.cpp         | 113 ++++++++++++-----------------
 src/mlpack/tests/allknn_test.cpp         | 121 +++++++++++++------------------
 src/mlpack/tests/rectangle_tree_test.cpp |  12 +--
 src/mlpack/tests/to_string_test.cpp      |   2 +-
 4 files changed, 104 insertions(+), 144 deletions(-)

diff --git a/src/mlpack/tests/allkfn_test.cpp b/src/mlpack/tests/allkfn_test.cpp
index 921c13a..ea7039a 100644
--- a/src/mlpack/tests/allkfn_test.cpp
+++ b/src/mlpack/tests/allkfn_test.cpp
@@ -57,10 +57,10 @@ BOOST_AUTO_TEST_CASE(ExhaustiveSyntheticTest)
     switch (i)
     {
       case 0: // Use the dual-tree method.
-        allkfn = new AllkFN(tree, dataMutable, false);
+        allkfn = new AllkFN(tree, false);
         break;
       case 1: // Use the single-tree method.
-        allkfn = new AllkFN(tree, dataMutable, true);
+        allkfn = new AllkFN(tree, true);
         break;
       case 2: // Use the naive method.
         allkfn = new AllkFN(dataMutable, true);
@@ -335,33 +335,27 @@ BOOST_AUTO_TEST_CASE(ExhaustiveSyntheticTest)
  */
 BOOST_AUTO_TEST_CASE(DualTreeVsNaive1)
 {
-  arma::mat dataForTree;
+  arma::mat dataset;
 
-  // Hard-coded filename: bad!
-  if (!data::Load("test_data_3_1000.csv", dataForTree))
+  // Hard-coded filename: bad?
+  if (!data::Load("test_data_3_1000.csv", dataset))
     BOOST_FAIL("Cannot load test dataset test_data_3_1000.csv!");
 
-  // Set up matrices to work with.
-  arma::mat dualQuery(dataForTree);
-  arma::mat dualReferences(dataForTree);
-  arma::mat naiveQuery(dataForTree);
-  arma::mat naiveReferences(dataForTree);
+  AllkFN allkfn(dataset);
 
-  AllkFN allkfn(dualQuery, dualReferences);
+  AllkFN naive(dataset, true);
 
-  AllkFN naive(naiveQuery, naiveReferences, true);
-
-  arma::Mat<size_t> resultingNeighborsTree;
+  arma::Mat<size_t> neighborsTree;
   arma::mat distancesTree;
-  allkfn.Search(15, resultingNeighborsTree, distancesTree);
+  allkfn.Search(dataset, 15, neighborsTree, distancesTree);
 
-  arma::Mat<size_t> resultingNeighborsNaive;
+  arma::Mat<size_t> neighborsNaive;
   arma::mat distancesNaive;
-  naive.Search(15, resultingNeighborsNaive, distancesNaive);
+  naive.Search(dataset, 15, neighborsNaive, distancesNaive);
 
-  for (size_t i = 0; i < resultingNeighborsTree.n_elem; i++)
+  for (size_t i = 0; i < neighborsTree.n_elem; i++)
   {
-    BOOST_REQUIRE(resultingNeighborsTree[i] == resultingNeighborsNaive[i]);
+    BOOST_REQUIRE(neighborsTree[i] == neighborsNaive[i]);
     BOOST_REQUIRE_CLOSE(distancesTree[i], distancesNaive[i], 1e-5);
   }
 }
@@ -374,32 +368,28 @@ BOOST_AUTO_TEST_CASE(DualTreeVsNaive1)
  */
 BOOST_AUTO_TEST_CASE(DualTreeVsNaive2)
 {
-  arma::mat dataForTree;
+  arma::mat dataset;
 
-  // Hard-coded filename: bad!
+  // Hard-coded filename: bad?
   // Code duplication: also bad!
-  if (!data::Load("test_data_3_1000.csv", dataForTree))
+  if (!data::Load("test_data_3_1000.csv", dataset))
     BOOST_FAIL("Cannot load test dataset test_data_3_1000.csv!");
 
-  // Set up matrices to work with.
-  arma::mat dualReferences(dataForTree);
-  arma::mat naiveReferences(dataForTree);
-
-  AllkFN allkfn(dualReferences);
+  AllkFN allkfn(dataset);
 
-  AllkFN naive(naiveReferences, true);
+  AllkFN naive(dataset, true);
 
-  arma::Mat<size_t> resultingNeighborsTree;
+  arma::Mat<size_t> neighborsTree;
   arma::mat distancesTree;
-  allkfn.Search(15, resultingNeighborsTree, distancesTree);
+  allkfn.Search(15, neighborsTree, distancesTree);
 
-  arma::Mat<size_t> resultingNeighborsNaive;
+  arma::Mat<size_t> neighborsNaive;
   arma::mat distancesNaive;
-  naive.Search(15, resultingNeighborsNaive, distancesNaive);
+  naive.Search(15, neighborsNaive, distancesNaive);
 
-  for (size_t i = 0; i < resultingNeighborsTree.n_elem; i++)
+  for (size_t i = 0; i < neighborsTree.n_elem; i++)
   {
-    BOOST_REQUIRE(resultingNeighborsTree[i] == resultingNeighborsNaive[i]);
+    BOOST_REQUIRE_EQUAL(neighborsTree[i], neighborsNaive[i]);
     BOOST_REQUIRE_CLOSE(distancesTree[i], distancesNaive[i], 1e-5);
   }
 }
@@ -412,31 +402,28 @@ BOOST_AUTO_TEST_CASE(DualTreeVsNaive2)
  */
 BOOST_AUTO_TEST_CASE(SingleTreeVsNaive)
 {
-  arma::mat dataForTree;
+  arma::mat dataset;
 
   // Hard-coded filename: bad!
   // Code duplication: also bad!
-  if (!data::Load("test_data_3_1000.csv", dataForTree))
+  if (!data::Load("test_data_3_1000.csv", dataset))
     BOOST_FAIL("Cannot load test dataset test_data_3_1000.csv!");
 
-  arma::mat singleQuery(dataForTree);
-  arma::mat naiveQuery(dataForTree);
+  AllkFN allkfn(dataset, false, true);
 
-  AllkFN allkfn(singleQuery, false, true);
+  AllkFN naive(dataset, true);
 
-  AllkFN naive(naiveQuery, true);
-
-  arma::Mat<size_t> resultingNeighborsTree;
+  arma::Mat<size_t> neighborsTree;
   arma::mat distancesTree;
-  allkfn.Search(15, resultingNeighborsTree, distancesTree);
+  allkfn.Search(15, neighborsTree, distancesTree);
 
-  arma::Mat<size_t> resultingNeighborsNaive;
+  arma::Mat<size_t> neighborsNaive;
   arma::mat distancesNaive;
-  naive.Search(15, resultingNeighborsNaive, distancesNaive);
+  naive.Search(15, neighborsNaive, distancesNaive);
 
-  for (size_t i = 0; i < resultingNeighborsTree.n_elem; i++)
+  for (size_t i = 0; i < neighborsTree.n_elem; i++)
   {
-    BOOST_REQUIRE(resultingNeighborsTree[i] == resultingNeighborsNaive[i]);
+    BOOST_REQUIRE_EQUAL(neighborsTree[i], neighborsNaive[i]);
     BOOST_REQUIRE_CLOSE(distancesTree[i], distancesNaive[i], 1e-5);
   }
 }
@@ -452,25 +439,24 @@ BOOST_AUTO_TEST_CASE(SingleCoverTreeTest)
   arma::mat data;
   data.randu(75, 1000); // 75 dimensional, 1000 points.
 
-  arma::mat naiveQuery(data); // For naive AllkNN.
-
+  // This depends on the cover tree not mapping points.
   CoverTree<LMetric<2>, FirstPointIsRoot,
       NeighborSearchStat<FurthestNeighborSort> > tree = CoverTree<LMetric<2>,
       FirstPointIsRoot, NeighborSearchStat<FurthestNeighborSort> >(data);
 
   NeighborSearch<FurthestNeighborSort, LMetric<2>, CoverTree<LMetric<2>,
       FirstPointIsRoot, NeighborSearchStat<FurthestNeighborSort> > >
-      coverTreeSearch(&tree, data, true);
+      coverTreeSearch(&tree, true);
 
-  AllkFN naive(naiveQuery, true);
+  AllkFN naive(data, true);
 
   arma::Mat<size_t> coverTreeNeighbors;
   arma::mat coverTreeDistances;
-  coverTreeSearch.Search(15, coverTreeNeighbors, coverTreeDistances);
+  coverTreeSearch.Search(data, 15, coverTreeNeighbors, coverTreeDistances);
 
   arma::Mat<size_t> naiveNeighbors;
   arma::mat naiveDistances;
-  naive.Search(15, naiveNeighbors, naiveDistances);
+  naive.Search(data, 15, naiveNeighbors, naiveDistances);
 
   for (size_t i = 0; i < coverTreeNeighbors.n_elem; ++i)
   {
@@ -488,13 +474,11 @@ BOOST_AUTO_TEST_CASE(DualCoverTreeTest)
   arma::mat dataset;
   data::Load("test_data_3_1000.csv", dataset);
 
-  arma::mat kdtreeData(dataset);
-
-  AllkFN tree(kdtreeData);
+  AllkFN tree(dataset);
 
   arma::Mat<size_t> kdNeighbors;
   arma::mat kdDistances;
-  tree.Search(5, kdNeighbors, kdDistances);
+  tree.Search(dataset, 5, kdNeighbors, kdDistances);
 
   typedef CoverTree<LMetric<2, true>, FirstPointIsRoot,
       NeighborSearchStat<FurthestNeighborSort> > TreeType;
@@ -502,11 +486,11 @@ BOOST_AUTO_TEST_CASE(DualCoverTreeTest)
   TreeType referenceTree = TreeType(dataset);
 
   NeighborSearch<FurthestNeighborSort, LMetric<2, true>,
-      TreeType> coverTreeSearch(&referenceTree, dataset);
+      TreeType> coverTreeSearch(&referenceTree);
 
   arma::Mat<size_t> coverNeighbors;
   arma::mat coverDistances;
-  coverTreeSearch.Search(5, coverNeighbors, coverDistances);
+  coverTreeSearch.Search(&referenceTree, 5, coverNeighbors, coverDistances);
 
   for (size_t i = 0; i < coverNeighbors.n_elem; ++i)
   {
@@ -531,14 +515,13 @@ BOOST_AUTO_TEST_CASE(SingleBallTreeTest)
   TreeType tree = TreeType(data);
 
   // BinarySpaceTree modifies data. Use modified data to maintain the
-  // correspondance between points in the dataset for both methods. The order of
+  // correspondence between points in the dataset for both methods. The order of
   // query points in both methods should be same.
-  arma::mat naiveQuery(data); // For naive AllkNN.
 
   NeighborSearch<FurthestNeighborSort, LMetric<2>, TreeType>
-      ballTreeSearch(&tree, data, true);
+      ballTreeSearch(&tree, true);
 
-  AllkFN naive(naiveQuery, true);
+  AllkFN naive(data, true);
 
   arma::Mat<size_t> ballTreeNeighbors;
   arma::mat ballTreeDistances;
@@ -564,9 +547,7 @@ BOOST_AUTO_TEST_CASE(DualBallTreeTest)
   arma::mat dataset;
   data::Load("test_data_3_1000.csv", dataset);
 
-  arma::mat kdtreeData(dataset);
-
-  AllkFN tree(kdtreeData);
+  AllkFN tree(dataset);
 
   arma::Mat<size_t> kdNeighbors;
   arma::mat kdDistances;
diff --git a/src/mlpack/tests/allknn_test.cpp b/src/mlpack/tests/allknn_test.cpp
index da9ed2c..91a8aca 100644
--- a/src/mlpack/tests/allknn_test.cpp
+++ b/src/mlpack/tests/allknn_test.cpp
@@ -200,10 +200,10 @@ BOOST_AUTO_TEST_CASE(ExhaustiveSyntheticTest)
     switch (i)
     {
       case 0: // Use the dual-tree method.
-        allknn = new AllkNN(tree, dataMutable, false);
+        allknn = new AllkNN(tree, false);
         break;
       case 1: // Use the single-tree method.
-        allknn = new AllkNN(tree, dataMutable, true);
+        allknn = new AllkNN(tree, true);
         break;
       case 2: // Use the naive method.
         allknn = new AllkNN(dataMutable, true);
@@ -478,33 +478,27 @@ BOOST_AUTO_TEST_CASE(ExhaustiveSyntheticTest)
  */
 BOOST_AUTO_TEST_CASE(DualTreeVsNaive1)
 {
-  arma::mat dataForTree;
+  arma::mat dataset;
 
-  // Hard-coded filename: bad!
-  if (!data::Load("test_data_3_1000.csv", dataForTree))
+  // Hard-coded filename: bad?
+  if (!data::Load("test_data_3_1000.csv", dataset))
     BOOST_FAIL("Cannot load test dataset test_data_3_1000.csv!");
 
-  // Set up matrices to work with.
-  arma::mat dualQuery(dataForTree);
-  arma::mat dualReferences(dataForTree);
-  arma::mat naiveQuery(dataForTree);
-  arma::mat naiveReferences(dataForTree);
-
-  AllkNN allknn(dualQuery, dualReferences);
+  AllkNN allknn(dataset);
 
-  AllkNN naive(naiveQuery, naiveReferences, true);
+  AllkNN naive(dataset, true);
 
-  arma::Mat<size_t> resultingNeighborsTree;
+  arma::Mat<size_t> neighborsTree;
   arma::mat distancesTree;
-  allknn.Search(15, resultingNeighborsTree, distancesTree);
+  allknn.Search(dataset, 15, neighborsTree, distancesTree);
 
-  arma::Mat<size_t> resultingNeighborsNaive;
+  arma::Mat<size_t> neighborsNaive;
   arma::mat distancesNaive;
-  naive.Search(15, resultingNeighborsNaive, distancesNaive);
+  naive.Search(dataset, 15, neighborsNaive, distancesNaive);
 
-  for (size_t i = 0; i < resultingNeighborsTree.n_elem; i++)
+  for (size_t i = 0; i < neighborsTree.n_elem; i++)
   {
-    BOOST_REQUIRE(resultingNeighborsTree(i) == resultingNeighborsNaive(i));
+    BOOST_REQUIRE_EQUAL(neighborsTree(i), neighborsNaive(i));
     BOOST_REQUIRE_CLOSE(distancesTree(i), distancesNaive(i), 1e-5);
   }
 }
@@ -517,33 +511,29 @@ BOOST_AUTO_TEST_CASE(DualTreeVsNaive1)
  */
 BOOST_AUTO_TEST_CASE(DualTreeVsNaive2)
 {
-  arma::mat dataForTree;
+  arma::mat dataset;
 
-  // Hard-coded filename: bad!
+  // Hard-coded filename: bad?
   // Code duplication: also bad!
-  if (!data::Load("test_data_3_1000.csv", dataForTree))
+  if (!data::Load("test_data_3_1000.csv", dataset))
     BOOST_FAIL("Cannot load test dataset test_data_3_1000.csv!");
 
-  // Set up matrices to work with (may not be necessary with no ALIAS_MATRIX?).
-  arma::mat dualQuery(dataForTree);
-  arma::mat naiveQuery(dataForTree);
-
-  AllkNN allknn(dualQuery);
+  AllkNN allknn(dataset);
 
   // Set naive mode.
-  AllkNN naive(naiveQuery, true);
+  AllkNN naive(dataset, true);
 
-  arma::Mat<size_t> resultingNeighborsTree;
+  arma::Mat<size_t> neighborsTree;
   arma::mat distancesTree;
-  allknn.Search(15, resultingNeighborsTree, distancesTree);
+  allknn.Search(15, neighborsTree, distancesTree);
 
-  arma::Mat<size_t> resultingNeighborsNaive;
+  arma::Mat<size_t> neighborsNaive;
   arma::mat distancesNaive;
-  naive.Search(15, resultingNeighborsNaive, distancesNaive);
+  naive.Search(15, neighborsNaive, distancesNaive);
 
-  for (size_t i = 0; i < resultingNeighborsTree.n_elem; i++)
+  for (size_t i = 0; i < neighborsTree.n_elem; i++)
   {
-    BOOST_REQUIRE(resultingNeighborsTree[i] == resultingNeighborsNaive[i]);
+    BOOST_REQUIRE_EQUAL(neighborsTree[i], neighborsNaive[i]);
     BOOST_REQUIRE_CLOSE(distancesTree[i], distancesNaive[i], 1e-5);
   }
 }
@@ -556,33 +546,29 @@ BOOST_AUTO_TEST_CASE(DualTreeVsNaive2)
  */
 BOOST_AUTO_TEST_CASE(SingleTreeVsNaive)
 {
-  arma::mat dataForTree;
+  arma::mat dataset;
 
-  // Hard-coded filename: bad!
+  // Hard-coded filename: bad?
   // Code duplication: also bad!
-  if (!data::Load("test_data_3_1000.csv", dataForTree))
+  if (!data::Load("test_data_3_1000.csv", dataset))
     BOOST_FAIL("Cannot load test dataset test_data_3_1000.csv!");
 
-  // Set up matrices to work with (may not be necessary with no ALIAS_MATRIX?).
-  arma::mat singleQuery(dataForTree);
-  arma::mat naiveQuery(dataForTree);
-
-  AllkNN allknn(singleQuery, false, true);
+  AllkNN allknn(dataset, false, true);
 
   // Set up computation for naive mode.
-  AllkNN naive(naiveQuery, true);
+  AllkNN naive(dataset, true);
 
-  arma::Mat<size_t> resultingNeighborsTree;
+  arma::Mat<size_t> neighborsTree;
   arma::mat distancesTree;
-  allknn.Search(15, resultingNeighborsTree, distancesTree);
+  allknn.Search(15, neighborsTree, distancesTree);
 
-  arma::Mat<size_t> resultingNeighborsNaive;
+  arma::Mat<size_t> neighborsNaive;
   arma::mat distancesNaive;
-  naive.Search(15, resultingNeighborsNaive, distancesNaive);
+  naive.Search(15, neighborsNaive, distancesNaive);
 
-  for (size_t i = 0; i < resultingNeighborsTree.n_elem; i++)
+  for (size_t i = 0; i < neighborsTree.n_elem; i++)
   {
-    BOOST_REQUIRE(resultingNeighborsTree[i] == resultingNeighborsNaive[i]);
+    BOOST_REQUIRE_EQUAL(neighborsTree[i], neighborsNaive[i]);
     BOOST_REQUIRE_CLOSE(distancesTree[i], distancesNaive[i], 1e-5);
   }
 }
@@ -598,17 +584,15 @@ BOOST_AUTO_TEST_CASE(SingleCoverTreeTest)
   arma::mat data;
   data.randu(75, 1000); // 75 dimensional, 1000 points.
 
-  arma::mat naiveQuery(data); // For naive AllkNN.
-
   CoverTree<LMetric<2>, FirstPointIsRoot,
       NeighborSearchStat<NearestNeighborSort> > tree = CoverTree<LMetric<2>,
       FirstPointIsRoot, NeighborSearchStat<NearestNeighborSort> >(data);
 
   NeighborSearch<NearestNeighborSort, LMetric<2>, CoverTree<LMetric<2>,
       FirstPointIsRoot, NeighborSearchStat<NearestNeighborSort> > >
-      coverTreeSearch(&tree, data, true);
+      coverTreeSearch(&tree, true);
 
-  AllkNN naive(naiveQuery, true);
+  AllkNN naive(data, true);
 
   arma::Mat<size_t> coverTreeNeighbors;
   arma::mat coverTreeDistances;
@@ -634,13 +618,11 @@ BOOST_AUTO_TEST_CASE(DualCoverTreeTest)
   arma::mat dataset;
   data::Load("test_data_3_1000.csv", dataset);
 
-  arma::mat kdtreeData(dataset);
-
-  AllkNN tree(kdtreeData);
+  AllkNN tree(dataset);
 
   arma::Mat<size_t> kdNeighbors;
   arma::mat kdDistances;
-  tree.Search(5, kdNeighbors, kdDistances);
+  tree.Search(dataset, 5, kdNeighbors, kdDistances);
 
   CoverTree<LMetric<2, true>, FirstPointIsRoot,
       NeighborSearchStat<NearestNeighborSort> > referenceTree = CoverTree<
@@ -650,11 +632,11 @@ BOOST_AUTO_TEST_CASE(DualCoverTreeTest)
   NeighborSearch<NearestNeighborSort, LMetric<2, true>,
       CoverTree<LMetric<2, true>, FirstPointIsRoot,
       NeighborSearchStat<NearestNeighborSort> > >
-      coverTreeSearch(&referenceTree, dataset);
+      coverTreeSearch(&referenceTree);
 
   arma::Mat<size_t> coverNeighbors;
   arma::mat coverDistances;
-  coverTreeSearch.Search(5, coverNeighbors, coverDistances);
+  coverTreeSearch.Search(&referenceTree, 5, coverNeighbors, coverDistances);
 
   for (size_t i = 0; i < coverNeighbors.n_elem; ++i)
   {
@@ -681,20 +663,19 @@ BOOST_AUTO_TEST_CASE(SingleBallTreeTest)
   // BinarySpaceTree modifies data. Use modified data to maintain the
   // correspondance between points in the dataset for both methods. The order of
   // query points in both methods should be same.
-  arma::mat naiveQuery(data); // For naive AllkNN.
 
   NeighborSearch<NearestNeighborSort, LMetric<2>, TreeType>
-      ballTreeSearch(&tree, data, true);
+      ballTreeSearch(&tree, true);
 
-  AllkNN naive(naiveQuery, true);
+  AllkNN naive(data, true);
 
   arma::Mat<size_t> ballTreeNeighbors;
   arma::mat ballTreeDistances;
-  ballTreeSearch.Search(1, ballTreeNeighbors, ballTreeDistances);
+  ballTreeSearch.Search(2, ballTreeNeighbors, ballTreeDistances);
 
   arma::Mat<size_t> naiveNeighbors;
   arma::mat naiveDistances;
-  naive.Search(1, naiveNeighbors, naiveDistances);
+  naive.Search(2, naiveNeighbors, naiveDistances);
 
   for (size_t i = 0; i < ballTreeNeighbors.n_elem; ++i)
   {
@@ -712,9 +693,7 @@ BOOST_AUTO_TEST_CASE(DualBallTreeTest)
   arma::mat dataset;
   data::Load("test_data_3_1000.csv", dataset);
 
-  arma::mat kdtreeData(dataset);
-
-  AllkNN tree(kdtreeData);
+  AllkNN tree(dataset);
 
   arma::Mat<size_t> kdNeighbors;
   arma::mat kdDistances;
@@ -756,16 +735,16 @@ BOOST_AUTO_TEST_CASE(SparseAllkNNKDTreeTest)
   typedef NeighborSearch<NearestNeighborSort, EuclideanDistance, SparseKDTree>
       SparseAllkNN;
 
-  SparseAllkNN a(queryDataset, referenceDataset);
-  AllkNN naive(denseQuery, denseReference, true);
+  SparseAllkNN a(referenceDataset);
+  AllkNN naive(denseReference, true);
 
   arma::mat sparseDistances;
   arma::Mat<size_t> sparseNeighbors;
-  a.Search(10, sparseNeighbors, sparseDistances);
+  a.Search(queryDataset, 10, sparseNeighbors, sparseDistances);
 
   arma::mat naiveDistances;
   arma::Mat<size_t> naiveNeighbors;
-  naive.Search(10, naiveNeighbors, naiveDistances);
+  naive.Search(denseQuery, 10, naiveNeighbors, naiveDistances);
 
   for (size_t i = 0; i < naiveNeighbors.n_cols; ++i)
   {
diff --git a/src/mlpack/tests/rectangle_tree_test.cpp b/src/mlpack/tests/rectangle_tree_test.cpp
index 5683d15..66cf480 100644
--- a/src/mlpack/tests/rectangle_tree_test.cpp
+++ b/src/mlpack/tests/rectangle_tree_test.cpp
@@ -471,11 +471,11 @@ BOOST_AUTO_TEST_CASE(PointDeletion)
 
   // Single-tree search.
   NeighborSearch<NearestNeighborSort, metric::LMetric<2, true>, TreeType>
-      allknn1(&tree, NULL, dataset, querySet, true);
+      allknn1(&tree, true);
 
   arma::Mat<size_t> neighbors1;
   arma::mat distances1;
-  allknn1.Search(5, neighbors1, distances1);
+  allknn1.Search(querySet, 5, neighbors1, distances1);
 
   arma::mat newDataset;
   newDataset = dataset;
@@ -485,9 +485,9 @@ BOOST_AUTO_TEST_CASE(PointDeletion)
   arma::mat distances2;
 
   // Nearest neighbor search the naive way.
-  AllkNN allknn2(newDataset, querySet, true, true);
+  AllkNN allknn2(newDataset, true, true);
 
-  allknn2.Search(5, neighbors2, distances2);
+  allknn2.Search(querySet, 5, neighbors2, distances2);
 
   for (size_t i = 0; i < neighbors1.size(); i++)
   {
@@ -562,7 +562,7 @@ BOOST_AUTO_TEST_CASE(PointDynamicAdd)
 
   // Nearest neighbor search with the R tree.
   NeighborSearch<NearestNeighborSort, metric::LMetric<2, true>, TreeType>
-      allknn1(&tree, dataset, true);
+      allknn1(&tree, true);
 
   allknn1.Search(5, neighbors1, distances1);
 
@@ -600,7 +600,7 @@ BOOST_AUTO_TEST_CASE(SingleTreeTraverserTest)
 
   // Nearest neighbor search with the R tree.
   NeighborSearch<NearestNeighborSort, metric::LMetric<2, true>, TreeType>
-      allknn1(&rTree, dataset, true);
+      allknn1(&rTree, true);
 
   BOOST_REQUIRE_EQUAL(rTree.NumDescendants(), 1000);
 
diff --git a/src/mlpack/tests/to_string_test.cpp b/src/mlpack/tests/to_string_test.cpp
index a95b54d..7abec83 100644
--- a/src/mlpack/tests/to_string_test.cpp
+++ b/src/mlpack/tests/to_string_test.cpp
@@ -445,7 +445,7 @@ BOOST_AUTO_TEST_CASE(NeighborString)
 {
   arma::mat c(40, 40);
   c.randn();
-  mlpack::neighbor::NeighborSearch<> d(c, c);
+  mlpack::neighbor::NeighborSearch<> d(c);
   Log::Debug << d;
   testOstream << d;
   std::string s = d.ToString();



More information about the mlpack-git mailing list