[mlpack-svn] r14418 - mlpack/trunk/src/mlpack/tests

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Feb 28 14:16:04 EST 2013


Author: rcurtin
Date: 2013-02-28 14:16:03 -0500 (Thu, 28 Feb 2013)
New Revision: 14418

Modified:
   mlpack/trunk/src/mlpack/tests/sort_policy_test.cpp
   mlpack/trunk/src/mlpack/tests/tree_test.cpp
Log:
Add test for Dataset() and update because the empty BinarySpaceTree constructor
no longer exists.


Modified: mlpack/trunk/src/mlpack/tests/sort_policy_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/sort_policy_test.cpp	2013-02-28 19:15:25 UTC (rev 14417)
+++ mlpack/trunk/src/mlpack/tests/sort_policy_test.cpp	2013-02-28 19:16:03 UTC (rev 14418)
@@ -94,7 +94,9 @@
 {
   // Well, there's no easy way to make HRectBounds the way we want, so we have
   // to make them and then expand the region to include new points.
-  tree::BinarySpaceTree<HRectBound<2>, arma::mat> nodeOne;
+  arma::mat dataset("1");
+  tree::BinarySpaceTree<HRectBound<2>, tree::EmptyStatistic, arma::mat>
+      nodeOne(dataset);
   arma::vec utility(1);
   utility[0] = 0;
 
@@ -103,7 +105,8 @@
   utility[0] = 1;
   nodeOne.Bound() |= utility;
 
-  tree::BinarySpaceTree<HRectBound<2>, arma::mat> nodeTwo;
+  tree::BinarySpaceTree<HRectBound<2>, tree::EmptyStatistic, arma::mat>
+      nodeTwo(dataset);
   nodeTwo.Bound() = HRectBound<2>(1);
 
   utility[0] = 5;
@@ -148,7 +151,8 @@
   arma::vec utility(1);
   utility[0] = 0;
 
-  tree::BinarySpaceTree<HRectBound<2>, arma::mat> node;
+  arma::mat dataset("1");
+  tree::BinarySpaceTree<HRectBound<2> > node(dataset);
   node.Bound() = HRectBound<2>(1);
   node.Bound() |= utility;
   utility[0] = 1;
@@ -251,13 +255,14 @@
   arma::vec utility(1);
   utility[0] = 0;
 
-  tree::BinarySpaceTree<HRectBound<2>, arma::mat> nodeOne;
+  arma::mat dataset("1");
+  tree::BinarySpaceTree<HRectBound<2> > nodeOne(dataset);
   nodeOne.Bound() = HRectBound<2>(1);
   nodeOne.Bound() |= utility;
   utility[0] = 1;
   nodeOne.Bound() |= utility;
 
-  tree::BinarySpaceTree<HRectBound<2>, arma::mat> nodeTwo;
+  tree::BinarySpaceTree<HRectBound<2> > nodeTwo(dataset);
   nodeTwo.Bound() = HRectBound<2>(1);
   utility[0] = 5;
   nodeTwo.Bound() |= utility;
@@ -301,7 +306,8 @@
   arma::vec utility(1);
   utility[0] = 0;
 
-  tree::BinarySpaceTree<HRectBound<2>, arma::mat> node;
+  arma::mat dataset("1");
+  tree::BinarySpaceTree<HRectBound<2> > node(dataset);
   node.Bound() = HRectBound<2>(1);
   node.Bound() |= utility;
   utility[0] = 1;

Modified: mlpack/trunk/src/mlpack/tests/tree_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/tree_test.cpp	2013-02-28 19:15:25 UTC (rev 14417)
+++ mlpack/trunk/src/mlpack/tests/tree_test.cpp	2013-02-28 19:16:03 UTC (rev 14418)
@@ -1516,6 +1516,27 @@
       rootNode.Right()->Left()->Right()->Parent());
 }
 
+BOOST_AUTO_TEST_CASE(CheckDataset)
+{
+  arma::mat dataset = "2.0 5.0 9.0 4.0 8.0 7.0;"
+                      "3.0 4.0 6.0 7.0 1.0 2.0 ";
+
+  // Leaf size of 1.
+  BinarySpaceTree<HRectBound<2> > rootNode(dataset, 1);
+
+  BOOST_REQUIRE_EQUAL(&rootNode.Dataset(), &dataset);
+  BOOST_REQUIRE_EQUAL(&rootNode.Left()->Dataset(), &dataset);
+  BOOST_REQUIRE_EQUAL(&rootNode.Right()->Dataset(), &dataset);
+  BOOST_REQUIRE_EQUAL(&rootNode.Left()->Left()->Dataset(), &dataset);
+  BOOST_REQUIRE_EQUAL(&rootNode.Left()->Right()->Dataset(), &dataset);
+  BOOST_REQUIRE_EQUAL(&rootNode.Right()->Left()->Dataset(), &dataset);
+  BOOST_REQUIRE_EQUAL(&rootNode.Right()->Right()->Dataset(), &dataset);
+  BOOST_REQUIRE_EQUAL(&rootNode.Left()->Left()->Left()->Dataset(), &dataset);
+  BOOST_REQUIRE_EQUAL(&rootNode.Left()->Left()->Right()->Dataset(), &dataset);
+  BOOST_REQUIRE_EQUAL(&rootNode.Right()->Left()->Left()->Dataset(), &dataset);
+  BOOST_REQUIRE_EQUAL(&rootNode.Right()->Left()->Right()->Dataset(), &dataset);
+}
+
 // Ensure FurthestDescendantDistance() works.
 BOOST_AUTO_TEST_CASE(FurthestDescendantDistanceTest)
 {
@@ -2102,13 +2123,14 @@
  */
 BOOST_AUTO_TEST_CASE(BinarySpaceTreeCopyConstructor)
 {
-  BinarySpaceTree<HRectBound<2> > b;
+  arma::mat data("1");
+  BinarySpaceTree<HRectBound<2> > b(data);
   b.Begin() = 10;
   b.Count() = 50;
-  b.Left() = new BinarySpaceTree<HRectBound<2> >();
+  b.Left() = new BinarySpaceTree<HRectBound<2> >(data);
   b.Left()->Begin() = 10;
   b.Left()->Count() = 30;
-  b.Right() = new BinarySpaceTree<HRectBound<2> >();
+  b.Right() = new BinarySpaceTree<HRectBound<2> >(data);
   b.Right()->Begin() = 40;
   b.Right()->Count() = 20;
 




More information about the mlpack-svn mailing list